NullShot Typescript MCP Template
A template repository for bootstrapping MCPs (Model Context Protocol) for the null-shot/typescript-agent-framework.
Getting Started
Setup the repository
Option A: Use nullshot cli
You can create a new project by following this interactive prompt:
Option B: Use deploy to cloudflare button
The following button will create a new repo in your organization and setup teh CI/CD using Cloudflare:
NOTE: The configuration only needs
Option C: Github Template
Click the "Use this template" button at the top of this repository
Clone your new repository
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
pnpm run dev: Runs both the MCP Inspector (port 6274) and Cloudflare Worker (port 8787) concurrentlypnpm start: Runs only the Cloudflare Worker (port 8787)pnpm test: Runs tests with Vitestpnpm run deploy: Deploys your MCP to Cloudflare Workerspnpm run cf-typegen: Generates TypeScript types for Cloudflare Workers (run this everytime you add new changes to wrangler.jsonc)
Usage Overview
There are two ways to leverage run an MCP Server with and without Hono for request routing.
Environment Setup
Optionally you can create a .dev.vars which will will bootstrap local enviornment variables or secrets.
When you run pnpm cf-typegen it generates worker-configuration.d.ts which creates an Env class for your code to access cloudflare bindings, env vars, and more.
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.
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
Creating 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
Examples
CRUD MCP Example - Leverage D1 Database
Expense MCP Example - Leveraging Workflows
Dependent Agent - AI Agent with MCP dependencies
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
Docs
Community
Join our community to get help, share ideas, and contribute to the project:
Discord: Join the
#typescript-frameworkchannel 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
git checkout -b feature/your-feature-nameCommit your changes: Make meaningful commits
git commit -m "Add feature: brief description"Push to your fork: Push your changes to your fork
git push origin feature/your-feature-nameCreate 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.
Or use the Deploy to Cloudflare button above to deploy directly from GitHub.