mcp-with-d1-data
If you are the rightful owner of mcp-with-d1-data and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This repository serves as a demonstration of building an MCP (Model Context Protocol) server that can access and query actual database information.
The MCP Server: Demo is a project that demonstrates the implementation of a Model Context Protocol server using the `@modelcontextprotocol/sdk` library. It leverages Cloudflare's `MCPAgent` to manage tools, resources, and a D1 database. The server is designed to interact with databases, providing schema management, query capabilities, and introspection tools. It is implemented as a Durable Object, allowing for stateful interactions and long process operations. The project includes integration tests to validate functionality and is structured to facilitate easy development and deployment on Cloudflare Workers.
Features
- Database Integration: Integrates with a D1 database to retrieve data, with SQL migration files for schema management.
- MCP Server Implementation: The `MyMCP` class extends `McpAgent` to provide server sent events (SSE) and durable object capabilities.
- Query Tool: Allows interaction with the database through SQL queries, with a focus on proper authorization safeguards.
- Introspection Tool: Helps the LLM understand the database structure for accurate query design.
- Integration Tests: Includes tests to validate the functionality of the MCP server and its tools.
Tools
query
Tool for interacting with the database by sending SQL queries.
schema-introspection
Tool for understanding the database structure to aid in query design.