Skip to content

Commit 4b47b20

Browse files
authored
43 mcp server for aimdb enable llm powered introspection (#44)
* add mcp design document * add aimdb-client module with connection, discovery and error handling * migrate aimdb-cli to use aimdb-client for connection and discovery * update embassy * initial implementation MCP protocol * update embassy * Implement notification file writer for MCP notifications * update embassy * update embassy * Add get_latest and get_latest_with_timeout methods to SyncConsumer * add schema help prompt and query_schema tool - Introduced a new prompt "schema-help" to assist users in querying and interpreting AimDB record schemas. - Implemented the `query_schema` tool to retrieve JSON schema and type information for records. - Added a new module `schema.rs` to handle schema-related functionalities, including inferring JSON schema from record values. - Updated the server and tools modules to integrate the new schema functionalities. - Enhanced the list of prompts and updated tests to include the new schema help prompt and query_schema tool. * fix clippy warning
1 parent 3e3f690 commit 4b47b20

54 files changed

Lines changed: 9116 additions & 311 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ AimDB is an async, in-memory database for real-time data synchronization across
99
-**Buffer Systems** - SPMC Ring, SingleLatest, Mailbox with simplified config
1010
-**Producer-Consumer** - Complete with typed patterns
1111
-**MQTT Connector** - Both std (rumqttc) and embedded (mountain-mqtt)
12+
-**MCP Server** - LLM-powered introspection with schema inference
1213
-**Examples & Tests** - Comprehensive coverage including embedded cross-compilation
1314
- 🚧 **Kafka/DDS Connectors** - Planned
1415
- 🚧 **CLI Tools** - Skeleton only
@@ -20,10 +21,66 @@ aimdb-executor/ # Runtime trait abstractions
2021
aimdb-tokio-adapter/ # Tokio runtime adapter
2122
aimdb-embassy-adapter/ # Embassy runtime adapter (configurable task pool)
2223
aimdb-mqtt-connector/ # MQTT for std and embedded
23-
examples/ # Working demos (tokio-mqtt, embassy-mqtt)
24+
aimdb-mcp/ # MCP server for LLM-powered introspection
25+
examples/ # Working demos (tokio-mqtt, embassy-mqtt, remote-access-demo)
2426
tools/aimdb-cli/ # CLI (skeleton)
2527
```
2628

29+
## AimDB MCP Tools
30+
31+
**IMPORTANT - Use MCP tools whenever possible for AimDB introspection:**
32+
33+
When working with running AimDB instances, **always prefer using the MCP tools** instead of writing custom code or using other methods. The MCP tools provide direct access to live database instances.
34+
35+
**Available MCP Tools:**
36+
- `mcp_aimdb_discover_instances` - Find running AimDB servers
37+
- `mcp_aimdb_list_records` - List all records in an instance
38+
- `mcp_aimdb_get_record` - Get current value of a record
39+
- `mcp_aimdb_set_record` - Set value of writable records
40+
- `mcp_aimdb_query_schema` - Infer JSON Schema from record values
41+
- `mcp_aimdb_subscribe_record` - Subscribe to real-time updates
42+
- `mcp_aimdb_unsubscribe_record` - Unsubscribe from updates
43+
- `mcp_aimdb_get_instance_info` - Get server version and capabilities
44+
- `mcp_aimdb_list_subscriptions` - List active subscriptions
45+
- `mcp_aimdb_get_notification_directory` - Get subscription data directory
46+
47+
**Usage Examples:**
48+
```
49+
# Find running instances
50+
mcp_aimdb_discover_instances()
51+
52+
# Query schema for a record
53+
mcp_aimdb_query_schema(
54+
socket_path: "/tmp/aimdb-demo.sock",
55+
record_name: "server::Config",
56+
include_example: true
57+
)
58+
59+
# Get record value
60+
mcp_aimdb_get_record(
61+
socket_path: "/tmp/aimdb-demo.sock",
62+
record_name: "server::Temperature"
63+
)
64+
65+
# Set writable record
66+
mcp_aimdb_set_record(
67+
socket_path: "/tmp/aimdb-demo.sock",
68+
record_name: "server::AppSettings",
69+
value: {"log_level": "debug", "max_connections": 100, "feature_flag_alpha": false}
70+
)
71+
```
72+
73+
**When to use MCP tools:**
74+
- ✅ Inspecting running AimDB instances
75+
- ✅ Testing record schemas and values
76+
- ✅ Debugging database state
77+
- ✅ Monitoring real-time data
78+
- ✅ Validating record configurations
79+
- ✅ Quick data exploration
80+
81+
**Test server:**
82+
The `examples/remote-access-demo` provides a test server with sample records at `/tmp/aimdb-demo.sock`.
83+
2784
## Development Workflow
2885

2986
**CRITICAL - Always test from workspace root:**

.vscode/mcp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"servers": {
3+
"aimdb": {
4+
"type": "stdio",
5+
"command": "/aimdb/target/debug/aimdb-mcp",
6+
"args": [],
7+
"env": {
8+
"RUST_LOG": "info"
9+
}
10+
}
11+
}
12+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"editor.formatOnSave": true,
44
"[rust]": {
55
"editor.defaultFormatter": "rust-lang.rust-analyzer"
6-
}
6+
},
7+
"makefile.configureOnOpen": false
78
}

Cargo.lock

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
members = [
33
"aimdb-executor",
44
"aimdb-core",
5+
"aimdb-client",
56
"aimdb-embassy-adapter",
67
"aimdb-tokio-adapter",
78
"aimdb-sync",
89
"aimdb-mqtt-connector",
910
"tools/aimdb-cli",
11+
"tools/aimdb-mcp",
1012
"examples/tokio-mqtt-connector-demo",
1113
"examples/embassy-mqtt-connector-demo",
1214
"examples/sync-api-demo",

0 commit comments

Comments
 (0)