Skip to main content
Glama
SuReaper

NullShot Typescript MCP Template

by SuReaper
mcp-quick-reference.mdc2.11 kB
--- description: "Quick reference for MCP development patterns" alwaysApply: false --- # MCP Development Quick Reference ## When Building MCP Servers ### Required Files & Structure - [server.ts](mdc:src/server.ts) - Main server class extending `McpHonoServerDO<Env>` - [tools.ts](mdc:src/tools.ts) - Function tools clients can call - [resources.ts](mdc:src/resources.ts) - Persistent data resources - [prompts.ts](mdc:src/prompts.ts) - Reusable message templates ### Quick Patterns **Tools** - Functions clients call: ```typescript server.tool('verb_noun', 'Description', { param: z.string().describe('...') }, async ({ param }) => { return { content: [{ type: "text", text: `Result: ${param}` }] }; }); ``` **Resources** - Data access: ```typescript server.resource('get_item', 'data://service/items/{id}', async (uri: URL) => { const id = uri.pathname.split('/').pop(); return { contents: [{ text: `Data for ${id}`, uri: uri.href }] }; }); ``` **Prompts** - Message templates: ```typescript server.prompt('help_topic', 'Description', () => ({ messages: [{ role: 'assistant', content: { type: 'text', text: 'Help content' } }] })); ``` **Custom Routes** - HTTP endpoints: ```typescript protected setupRoutes(app: Hono<{ Bindings: Env }>): void { super.setupRoutes(app); // ALWAYS call parent first app.get('/api/custom', (c) => c.json({ message: 'custom' })); } ``` ### Key Requirements - ✅ Use Zod schemas with `.describe()` for tool parameters - ✅ Always call `super.setupRoutes(app)` before adding custom routes - ✅ Return `content` array for tools, `contents` array for resources - ✅ Use snake_case for tool/resource/prompt names - ✅ Include error handling with try/catch - ✅ Access environment bindings via `c.env` in routes ### Import Checklist ```typescript import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { McpHonoServerDO } from '@nullshot/mcp'; import { z } from 'zod'; ``` See detailed patterns in [mcp-development.mdc](mdc:.cursor/rules/mcp-development.mdc) and [mcp-generation-patterns.mdc](mdc:.cursor/rules/mcp-generation-patterns.mdc).

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SuReaper/cortensor-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server