Built on Cloudflare Workers for edge computing capabilities, enabling deployment of the MCP server at the edge for lower latency and higher availability
Provides community support through Discord, specifically in the #mcp channel for feature requests and discussions
Integrates with Hono web framework for building custom HTTP endpoints alongside the MCP protocol handlers, providing a clean routing system and middleware capabilities
References SQLite database integration for persistence of data, as demonstrated in the CRUD example with full database operations
Integrates Vitest for running tests with a dedicated testing suite for WebSocket and SSE testing
Uses Zod schema validation for defining and validating parameters in tool definitions
Xava Labs Typescript MCP Template
A template repository for bootstrapping MCPs (Model Context Protocol) for the xava-labs/typescript-agent-framework.
Getting Started
Setup the repository
Option A: Use this template*
- Click the "Use this template" button at the top of this repository
- Clone your new repository
Option b: Use wrangler init
You can create a new project based on this template using wrangler:
Once you have completed one of the above methods, then run the following commands in your terminal to get started:
The above will boostrap a serverless cloudflare compatible MCP Server with the following urls:
- /ws - Websocket connection endpoint
- /sse - SSE connection endpoint
Features
- WebSocket Client Support: Includes official WebSocket client for real-time bidirectional communication
- SSE Client Support: Includes Server-Sent Events client for server-to-client streaming
- MCP Inspector: Debug and monitor your MCP during development
- Cloudflare Workers Integration: Built on Cloudflare Workers for edge computing capabilities
- Integration Testing Suite: Websocket and SSE testing tools to do full integration testing with local miniflare services (D1/KV/etc) for ease of testing features without mocking.
Available Scripts
yarn dev
: Runs both the MCP Inspector (port 6274) and Cloudflare Worker (port 8787) concurrentlyyarn start
: Runs only the Cloudflare Worker (port 8787)yarn test
: Runs tests with Vitestyarn deploy
: Deploys your MCP to Cloudflare Workersyarn cf-typegen
: Generates TypeScript types for Cloudflare Workers (run this everytime you add new changes to wrangler.jsonc)
Development
This template implements an MCP server using Durable Objects for stateful connections. The base project structure offers two main approaches for extending functionality:
McpHonoServerDO Implementation
By default, the template uses McpHonoServerDO
which combines the MCP server with Hono, a fast and lightweight web framework. This provides a clean routing system and middleware capabilities.
Extending with Tools, Resources, and Prompts
The main server implementation is in src/server.ts
and extends McpHonoServerDO
:
To add functionality, use the following modules:
- Tools (
src/tools.ts
): Define functions that clients can call
- Resources (
src/resources.ts
): Define persistent resources clients can access
- Prompts (
src/prompts.ts
): Define prompt templates
Customizing Routes with Hono
To add custom HTTP endpoints with McpHonoServerDO
, extend the setupRoutes
method:
McpServerDO Implementation (Native Cloudflare Routing)
If you need more control over the HTTP request handling, you can directly extend McpServerDO
instead. This gives you full control over the fetch
method:
This approach is useful when you need to:
- Handle specific routes with custom logic
- Implement complex middleware or authentication
- Intercept or modify requests before they reach the MCP handler
- Add custom WebSocket or SSE endpoints beyond the standard MCP implementation
Examples
CRUD Todo List Example
For a complete working example, check out the CRUD Todo List MCP Example which demonstrates:
- Full CRUD operations using MCP tools
- SQLite database integration for persistence
- Real-time updates via WebSocket/SSE
- Comprehensive error handling
- Advanced filtering and sorting capabilities
- Rich prompts and resources
Related Resources
Core Packages
- MCP Package: The core MCP implementation with advanced features and testing utilities
- TypeScript Agent Framework: Build intelligent agents powered by LLMs with the Agent Framework
Documentation
- Documentation: Coming soon!
Community
Join our community to get help, share ideas, and contribute to the project:
- Discord: Join the
#mcp
channel for feature requests, support, and discussions
Contributing
We welcome contributions to improve this template! Here's how you can contribute:
- Fork the repository: Create a fork to make your changes
- Create a branch: Make your changes in a new branch
- Commit your changes: Make meaningful commits
- Push to your fork: Push your changes to your fork
- Create a pull request: Open a PR with a detailed description of your changes
Pull Request Guidelines
- Provide a clear, descriptive title for your PR
- Include a detailed description of what your PR does
- Reference any related issues
- Include screenshots or examples if applicable
- Ensure all tests pass
- Keep PRs focused on a single feature or fix
For larger changes or features, we recommend discussing them first in our Discord channel to ensure alignment with the project direction.
Deployment
To deploy your MCP to Cloudflare Workers, run:
Or use the Deploy to Cloudflare button above to deploy directly from GitHub.
License
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A template repository for building Model Context Protocol (MCP) servers that enables developers to create interactive AI agents with real-time bidirectional communication capabilities through WebSocket and SSE endpoints.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.Last updated -13,4141,774TypeScriptMIT License
- AsecurityAlicenseAqualityA Model Context Protocol (MCP) server that exposes the official Notion SDK, allowing AI models to interact with Notion workspaces.Last updated -17777TypeScriptApache 2.0
- AsecurityFlicenseAqualityModel Context Protocol (MCP) server that integrates Redash with AI assistants like Claude, allowing them to query data, manage visualizations, and interact with dashboards through natural language.Last updated -1010421JavaScript
- AsecurityFlicenseAqualityA server implementing the Model Context Protocol (MCP) to support Agent8 SDK development by providing system prompts and code example search capabilities through stdio and SSE transports.Last updated -8TypeScript