A CLI tool to create MCP (Model Context Protocol) applications with ease.
- π Quick project scaffolding
- π¦ TypeScript support out of the box
- π οΈ Built-in development tools
- π§ Configurable project templates
- π Multiple Transport Modes (stdio/streamable-http/sse)
- π Comprehensive APIs
npm create mcp-kit@latest
or
yarn create mcp-kit@latest
or
pnpm create mcp-kit@latest
create-mcp-kit supports generating two types of projects:
Create an MCP server that provides tools, resources, and prompts for MCP clients.
The generated server project will have the following structure:
βββ src/
β βββ tools/ # MCP tools implementation
β β βββ index.ts # Tools registration
β β βββ register*.ts # Individual tool implementations
β βββ resources/ # MCP resources implementation
β β βββ index.ts # Resources registration
β βββ prompts/ # MCP prompts implementation
β β βββ index.ts # Prompts registration
β βββ services/ # Server implementations
β β βββ stdio.ts # STDIO transport implementation
β β βββ web.ts # Streamable HTTP and SSE transport implementation
β βββ index.ts # Entry point
βββ tests/ # Test files (optional)
βββ scripts/ # Build and development scripts
βββ .github/ # GitHub Actions workflows (optional)
βββ .husky/ # Git hooks (optional)
βββ .prettierrc # Prettier configuration (optional)
βββ changelog-option.js # Conventional changelog config (optional)
βββ commitlint.config.js # Commit message lint rules (optional)
βββ eslint.config.js # ESLint configuration (optional)
βββ lint-staged.config.js # Lint-staged configuration (optional)
βββ vitest.*.ts # Vitest configuration (optional)
βββ package.json
npm run dev- Start the development server in stdio modenpm run dev:web- Start the development server in web modenpm run build- Build the projectnpm run test- Run tests (if vitest plugin is selected)npm run coverage- Generate test coverage report (if vitest plugin is selected)npm run lint- Run linting (if style plugin is selected)
Create an MCP client that connects to MCP servers and uses their tools, resources, and prompts.
The generated client project will have the following structure:
βββ src/
β βββ index.ts # Entry point with transport implementations
βββ tests/ # Test files (optional)
βββ scripts/ # Build and development scripts
βββ .github/ # GitHub Actions workflows (optional)
βββ .husky/ # Git hooks (optional)
βββ .prettierrc # Prettier configuration (optional)
βββ changelog-option.js # Conventional changelog config (optional)
βββ commitlint.config.js # Commit message lint rules (optional)
βββ eslint.config.js # ESLint configuration (optional)
βββ lint-staged.config.js # Lint-staged configuration (optional)
βββ vitest.*.ts # Vitest configuration (optional)
βββ package.json
npm run dev- Start the client in development modenpm run build- Build the projectnpm run test- Run tests (if vitest plugin is selected)npm run coverage- Generate test coverage report (if vitest plugin is selected)npm run lint- Run linting (if style plugin is selected)
MCP Server supports three transport modes:
- STDIO: Communication through standard input/output streams
- Streamable HTTP: RESTful API with streaming capabilities
- SSE (Server-Sent Events): Real-time event streaming from server to client
Implement custom tools that can be used by MCP clients:
// Full implementation example import { z } from 'zod' import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' export default function register(server, options) { server.registerTool( 'GetData', { title: 'Get Data', description: 'Get Data', inputSchema: { keyword: z.string().describe('search keyword'), }, }, async ({ keyword }) => { const { success, data, message } = await getData(keyword, options) return { content: [ { type: 'text', text: success ? data : message, }, ], } }, ) } export const getData = async (keyword, options) => { if (!keyword || keyword === 'error') { return { success: false, message: 'Invalid keyword', } } return { success: true, data: `Data for ${keyword}`, } }
Define resources that can be accessed by MCP clients:
// Full implementation example import { type McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js' import type { OptionsType } from '@/types' export const registerResources = (server: McpServer, options: OptionsType) => { server.registerResource( 'search', new ResourceTemplate('search://{keyword}', { list: undefined, }), { title: 'Search Resource', description: 'Dynamic generate search resource', }, async (uri, { keyword }) => { return { contents: [ { uri: uri.href, text: `search ${keyword}`, }, ], } }, ) }
Create reusable prompts for MCP clients:
// Full implementation example import { z } from 'zod' import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' export const registerPrompts = (server: McpServer) => { server.registerPrompt( 'echo', { title: 'Echo Prompt', description: 'Creates a prompt to process a message.', argsSchema: { message: z.string(), }, }, ({ message }) => { return { messages: [ { role: 'user', content: { type: 'text', text: `Please process this message: ${message}`, }, }, ], } }, ) }
Connect to MCP servers using different transport modes:
// Import the MCP client import { McpClient } from '@modelcontextprotocol/sdk/client/mcp.js' import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/transports/stdio.js' import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/transports/streamable-http.js' import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/transports/sse.js' // Create a new MCP client const client = new McpClient() // STDIO Transport const stdioClientTransport = new StdioClientTransport({ command: 'npx', args: ['-y', '@my-mcp-hub/node-mcp-server'], env: process.env, }) await client.connect(stdioClientTransport) // Streamable HTTP Transport const streamableBaseUrl = new URL('http://localhost:8401/mcp') const streamableClientTransport = new StreamableHTTPClientTransport(streamableBaseUrl) await client.connect(streamableClientTransport) // SSE Transport const sseBaseUrl = new URL('http://localhost:8401/sse') const sseClientTransport = new SSEClientTransport(sseBaseUrl) await client.connect(sseClientTransport)
Call tools provided by MCP servers:
// List available tools const tools = await client.listTools() console.log(tools) // Call a tool const callResult = await client.callTool({ name: 'GetData', arguments: { keyword: 'Hello', }, }) console.log(callResult.content)
Access resources provided by MCP servers:
// List available resources const resources = await client.listResources() console.log(resources) // Get a resource const resource = await client.getResource('search://example') console.log(resource.contents)
Use prompts provided by MCP servers:
// List available prompts const prompts = await client.listPrompts() console.log(prompts) // Use a prompt const prompt = await client.getPrompt('echo', { message: 'Hello, world!' }) console.log(prompt.messages)
Feel free to dive in! Open an issue or submit PRs.
Standard Readme follows the Contributor Covenant Code of Conduct.
This project exists thanks to all the people who contribute.
MIT Β© MichaelSun