Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
3.3 KiB
TS MCP Template (V1)
A Node.js template for building Model Context Protocol (MCP) servers with TypeScript. This template focuses on a local-first development experience, protocol-safe stdio execution, and explicit capability registration.
Status: V1 Alpha
This template supports:
- Node.js 20+ runtime
- Single-package architecture
- Protocol-safe Local Stdio transport (Primary)
- Streamable HTTP transport (Secondary)
- Explicit, function-based tool, resource, and prompt registration
- Vitest-powered transport and core logic testing
It does not currently support Bun, Deno, edge runtimes, built-in authentication, or telemetry.
Quickstart: Local Stdio
Stdio is the primary transport for local development and integration with desktop LLM clients like Claude.
-
Install dependencies
npm install -
Run with MCP Inspector The template includes a protocol-safe launch configuration in
package.jsonto avoid stdout pollution. Use this command to test your server:npx @modelcontextprotocol/inspector node ./node_modules/tsx/dist/cli.mjs src/stdio.ts -
Build the project To prepare for production or use with a compiled entry point:
npm run build
Usage: HTTP
The HTTP transport uses the Node-native StreamableHTTPServerTransport for remote or web-based connections.
-
Start the HTTP server
npm run dev:httpThe server defaults to
127.0.0.1:3000. You can configure the port via theHTTP_PORTenvironment variable. -
Endpoints
POST /mcp: Initialize a new session and handle requests.GET /mcp: Handle ongoing session requests.
Development and Testing
- Typecheck:
npm run typecheck - Test:
npm test(Runs Vitest smoke tests for stdio, HTTP, and core logic) - Dev (Core Logic):
npm run dev(Executessrc/index.ts)
Repository Structure
src/core/: The shared MCP core factory (createMcpCore) that builds the server and registry.src/capabilities/: Definitions and handlers for tools, resources, and prompts.src/stdio.ts: The stdio entry point and transport setup.src/http.ts: The HTTP entry point and session management.src/config/: Runtime configuration and environment variable parsing.src/lib/: Internal utilities, stderr-safe logging, and error handling.
Extension Guidance
This template uses an explicit, function-based registration pattern instead of decorators or reflection.
1. Define Contracts
Add new tool or prompt schemas in src/capabilities/contracts.ts to share types between handlers and tests.
2. Implement Handlers
Create or update files in src/capabilities/ (e.g., tools.ts):
- Define the handler logic.
- Update the
register...Capabilitiesfunction to add descriptors to the registry. - Update the
register...Handlersfunction to wire the logic to theMcpServerinstance.
3. Register with Core
If you create new capability modules, ensure they are called within src/capabilities/index.ts in the registerCoreCapabilities and registerCoreMcpCapabilities functions.
V1 Limitations
- No Auth: HTTP transport does not include built-in authentication.
- Node-only: Specifically tuned for Node.js 20+.
- No Monorepo: Designed as a standalone project template.
- Local Focus: Deployment guides for cloud providers are not provided in V1.