|
1 | | -# NDC-MCP Connector (Rust) |
| 1 | +# NDC-MCP Connector |
2 | 2 |
|
3 | | -A Native Data Connector (NDC) that bridges Hasura's Data Delivery Network (DDN) with the Model Context Protocol (MCP), enabling seamless integration between DDN Engine and MCP. This connector is written in Rust. |
| 3 | +A Native Data Connector (NDC) that bridges Hasura DDN with Model Context Protocol (MCP) servers, exposing MCP resources as collections and tools as functions/procedures. |
4 | 4 |
|
5 | | -## Overview |
| 5 | +## Features |
6 | 6 |
|
7 | | -This connector allows you to: |
| 7 | +- **Dynamic Schema Generation**: Automatically generates NDC schema from MCP server introspection |
| 8 | +- **Multiple Transports**: Supports stdio (local processes) and HTTP (remote servers) |
| 9 | +- **Multiple Servers**: Connect to multiple MCP servers simultaneously |
| 10 | +- **Resource Mapping**: MCP resources → NDC collections |
| 11 | +- **Tool Execution**: MCP tools → NDC functions/procedures |
| 12 | +- **Naming Convention**: `{server_name}__{resource_or_tool}` pattern |
8 | 13 |
|
9 | | -- Access MCP resources through NDC collections |
10 | | -- Execute read-only MCP tools through NDC functions |
11 | | -- Execute mutable MCP tools through NDC procedures |
12 | | -- Generate a dynamic NDC schema from MCP resources and tools |
| 14 | +## Quick Start |
13 | 15 |
|
14 | | -## Features |
| 16 | +1. **Clone and build**: |
15 | 17 |
|
16 | | -- **Dynamic Schema Generation**: Automatically generates an NDC schema from MCP resources and tools |
17 | | -- **Resource Mapping**: MCP resources are exposed as queryable collections in NDC |
18 | | -- **Tool Execution**: MCP tools can be executed through NDC functions and procedures |
19 | | -- **Multiple Server Support**: Connect to multiple MCP servers with different transport types |
20 | | -- **Naming Convention**: Uses a `{server_name}__{resource_or_tool}` pattern to uniquely identify resources and tools |
| 18 | + ```bash |
| 19 | + git clone https://github.com/hasura/ndc-mcp-rs.git |
| 20 | + cd ndc-mcp-rs |
| 21 | + cargo build |
| 22 | + ``` |
21 | 23 |
|
22 | | -## Prerequisites |
| 24 | +2. **Configure servers** in `configuration/servers.yaml`: |
| 25 | + |
| 26 | + ```yaml |
| 27 | + servers: |
| 28 | + filesystem: |
| 29 | + type: stdio |
| 30 | + command: npx |
| 31 | + args: |
| 32 | + ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"] |
| 33 | + |
| 34 | + remote: |
| 35 | + type: http |
| 36 | + url: "http://localhost:8080/mcp" |
| 37 | + headers: |
| 38 | + Authorization: "Bearer your-token" |
| 39 | + timeout_seconds: 30 |
| 40 | + ``` |
| 41 | +
|
| 42 | +3. **Generate configuration**: |
23 | 43 |
|
24 | | -- Rust 1.85.0 or later (with edition2024 support) |
25 | | -- An MCP server to connect to (e.g., a filesystem MCP server) |
| 44 | + ```bash |
| 45 | + just generate-config |
| 46 | + # or: cargo run --bin mcp-connector-cli -- --configuration configuration update --outfile configuration/configuration.json |
| 47 | + ``` |
26 | 48 |
|
27 | | -## Installation |
| 49 | +4. **Start the connector**: |
28 | 50 |
|
29 | | -1. Clone the repository: |
30 | 51 | ```bash |
31 | | - git clone https://github.com/hasura/ndc-mcp-rs.git |
32 | | - cd ndc-mcp-rs |
| 52 | + just serve |
| 53 | + # or: cargo run --bin mcp-connector -- serve --configuration configuration |
33 | 54 | ``` |
34 | 55 |
|
35 | | -2. Build the project: |
| 56 | +5. **Test the schema**: |
36 | 57 | ```bash |
37 | | - cargo build --release |
| 58 | + curl http://localhost:8080/schema | jq |
38 | 59 | ``` |
39 | 60 |
|
40 | 61 | ## Configuration |
41 | 62 |
|
42 | | -Create a `config.json` file in the `configuration` directory with the following structure: |
43 | | - |
44 | | -```json |
45 | | -{ |
46 | | - "servers": { |
47 | | - "filesystem": { |
48 | | - "type": "stdio", |
49 | | - "command": "secure-filesystem-server", |
50 | | - "args": ["--allowed-paths", "/path/to/allowed/directory"] |
51 | | - }, |
52 | | - "remote_server": { |
53 | | - "type": "http", |
54 | | - "url": "http://localhost:8080/mcp", |
55 | | - "headers": { |
56 | | - "Authorization": "Bearer your-token-here" |
57 | | - }, |
58 | | - "timeout_seconds": 30 |
59 | | - } |
60 | | - } |
61 | | -} |
62 | | -``` |
| 63 | +The connector uses a two-step configuration process: |
63 | 64 |
|
64 | | -You can configure multiple MCP servers with different transport types: |
| 65 | +1. **servers.yaml**: Define your MCP servers (this is what you edit) |
| 66 | +2. **configuration.json**: Generated automatically by introspecting the MCP servers |
65 | 67 |
|
66 | | -- **stdio**: For local MCP servers that communicate over standard input/output |
67 | | -- **http**: For remote MCP servers that communicate over streamable HTTP transport (recommended for HTTP-based servers) |
| 68 | +### Transport Types |
68 | 69 |
|
69 | | -## Usage |
| 70 | +- **stdio**: For local MCP servers (Node.js packages, Python scripts, etc.) |
| 71 | +- **http**: For remote MCP servers using streamable HTTP transport |
70 | 72 |
|
71 | | -1. Start the NDC-MCP connector: |
72 | | - ```bash |
73 | | - cargo run -- serve --configuration configuration |
74 | | - ``` |
| 73 | +## Development |
75 | 74 |
|
76 | | -2. The connector will start on port 8080 by default. You can now use it with Hasura or any other NDC client. |
| 75 | +```bash |
| 76 | +# Build |
| 77 | +just build |
77 | 78 |
|
78 | | -3. Access the schema: |
79 | | - ```bash |
80 | | - curl http://localhost:8080/schema | jq |
81 | | - ``` |
| 79 | +# Format code |
| 80 | +just format |
82 | 81 |
|
83 | | -## License |
| 82 | +# Run clippy |
| 83 | +just clippy |
| 84 | + |
| 85 | +# Generate config and serve |
| 86 | +just generate-config && just serve |
| 87 | +``` |
84 | 88 |
|
85 | | -This project is licensed under the MIT License - see the LICENSE file for details. |
| 89 | +## Prerequisites |
| 90 | + |
| 91 | +- Rust 1.85.0+ (edition 2021) |
| 92 | +- MCP servers to connect to |
86 | 93 |
|
87 | | -## Acknowledgements |
| 94 | +## License |
88 | 95 |
|
89 | | -- [Hasura NDC Specification](https://github.com/hasura/ndc-spec) |
90 | | -- [Model Context Protocol](https://github.com/hasura/rmcp) |
| 96 | +MIT License - see LICENSE file for details. |
0 commit comments