Typescript Boilerplate
No description available
Ask AI about Typescript Boilerplate
Powered by Claude Β· Grounded in docs
I know everything about Typescript Boilerplate. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
MCP TypeScript Boilerplate
A comprehensive TypeScript boilerplate for creating Model Context Protocol (MCP) servers with support for stdio, SSE, and HTTP transports.
π Features
- Multiple Transport Support: stdio, Server-Sent Events (SSE), and HTTP
- TypeScript: Full type safety and modern development experience
- Modular Architecture: Clean separation of tools, utilities, and server logic
- Structured Logging: Built-in logger with configurable levels
- Generic API Client: Reusable HTTP client with interceptors and error handling
- Tool Factory: Streamlined tool creation with validation and error handling
- Development Ready: Hot reload, linting, formatting, and type checking
π οΈ Getting Started
Prerequisites
- Node.js >= v18.0.0
- MCP Client (Cursor, VS Code, Claude Desktop, etc.)
Local Development
-
Clone and install:
git clone https://github.com/andradehenrique/mcp-typescript-boilerplate.git cd mcp-typescript-boilerplate npm install -
Build the project:
npm run build -
Run in different modes:
# Stdio mode (default) npm run start:stdio # HTTP server mode npm run start:http # Development with hot reload npm run dev
MCP Client Configuration
For Local Development
Configure your MCP client to use the built server directly:
{
"mcpServers": {
"mcp-typescript-boilerplate": {
"command": "node",
"args": ["/path/to/mcp-typescript-boilerplate/build/index.js"],
"env": {
"API_BASE_URL": "https://your-api-server.com/api",
"API_TOKEN": "your-api-token"
}
}
}
}
Using tsx for Development
{
"mcpServers": {
"mcp-typescript-boilerplate": {
"command": "npx",
"args": ["tsx", "/path/to/mcp-typescript-boilerplate/src/index.ts"],
"env": {
"API_BASE_URL": "https://your-api-server.com/api",
"API_TOKEN": "your-api-token"
}
}
}
}
Docker Support
-
Build and run:
docker build -t mcp-typescript-boilerplate . docker-compose up -
HTTP mode:
docker run -p 3000:3000 -e MCP_TRANSPORT=http mcp-typescript-boilerplate
Environment Variables
API_BASE_URL: Your API server base URL (optional)API_TOKEN: Your API authentication token (optional)API_TIMEOUT: Request timeout in milliseconds (default: 30000)MCP_TRANSPORT: Transport mode - stdio, http, or sse (default: stdio)HTTP_PORT: HTTP server port (default: 3000)
π Available Tools
This boilerplate includes 3 example tools:
hello-world- Simple greeting toolcalculate-sum- Number calculation examplemake-api-call- External API integration example
For detailed tool information, see TOOLS.md.
ποΈ Architecture
src/
βββ index.ts # Entry point with transport selection
βββ server.ts # MCP server setup and tool registration
βββ http-server.ts # HTTP/SSE server implementation
βββ mcp/
β βββ tools/
β βββ index.ts # Tool exports
β βββ toolFactory.ts # Tool creation utilities
β βββ example/ # Example tools
βββ types/ # TypeScript type definitions
βββ utils/ # Shared utilities
βββ apiClient.ts # HTTP client
βββ clientConfig.ts # Configuration
βββ logger.ts # Logging utilities
βββ responseFormatter.ts # Response formatting
π§ Creating Tools
Use the provided toolFactory for easy tool creation:
import { z } from "zod";
import { createTool } from "../toolFactory.js";
import { ResponseFormatter } from "../../utils/responseFormatter.js";
export const myTool = createTool({
name: "my-tool",
description: "My custom tool",
schema: z.object({
input: z.string().describe("Input parameter"),
}),
handler: async (input) => {
// Your logic here
return ResponseFormatter.success("Success", { result: input });
},
});
Add to src/mcp/tools/index.ts:
import { myTool } from "./myTool.js";
export const allTools = [
myTool,
// ... other tools
];
π Available Scripts
npm run build- Build the projectnpm run dev- Development with hot reloadnpm run start:stdio- Start in stdio modenpm run start:http- Start HTTP servernpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run type-check- Type checkingnpm run clean- Clean build directory
π§ Testing
Test with MCP Inspector:
npx @modelcontextprotocol/inspector node build/index.js
π€ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
See CONTRIBUTING.md for details.
π Resources
π License
This project is licensed under the MIT License.
