@@ -12,6 +12,8 @@ A CLI tool to create MCP (Model Context Protocol) applications with ease.
1212- 📦 TypeScript support out of the box
1313- 🛠️ Built-in development tools
1414- 🔧 Configurable project templates
15+ - 🌐 Multiple Transport Modes (stdio/streamable-http/sse)
16+ - 📚 Comprehensive APIs
1517
1618## Usage
1719
3133pnpm create mcp-kit@latest
3234```
3335
34- ## Project Structure
36+ ## Project Types
37+
38+ create-mcp-kit supports generating two types of projects:
39+
40+ ### MCP Server
41+
42+ Create an MCP server that provides tools, resources, and prompts for MCP clients.
43+
44+ #### Server Project Structure
3545
3646``` text
37- The generated project will have the following structure:
47+ The generated server project will have the following structure:
3848
3949├── src/
4050│ ├── tools/ # MCP tools implementation
51+ │ │ ├── index.ts # Tools registration
52+ │ │ └── register*.ts # Individual tool implementations
4153│ ├── resources/ # MCP resources implementation
54+ │ │ └── index.ts # Resources registration
4255│ ├── prompts/ # MCP prompts implementation
43- │ ├── services/ # Server implementations (stdio/web)
56+ │ │ └── index.ts # Prompts registration
57+ │ ├── services/ # Server implementations
58+ │ │ ├── stdio.ts # STDIO transport implementation
59+ │ │ └── web.ts # Streamable HTTP and SSE transport implementation
4460│ └── index.ts # Entry point
45- ├── tests/ # Test files
61+ ├── tests/ # Test files (optional)
62+ ├── scripts/ # Build and development scripts
63+ ├── .github/ # GitHub Actions workflows (optional)
64+ ├── .husky/ # Git hooks (optional)
65+ └── package.json
66+ ```
67+
68+ #### Server Development Scripts
69+
70+ - ` npm run dev ` - Start the development server in stdio mode
71+ - ` npm run dev:web ` - Start the development server in web mode
72+ - ` npm run build ` - Build the project
73+ - ` npm run test ` - Run tests (if vitest plugin is selected)
74+ - ` npm run coverage ` - Generate test coverage report (if vitest plugin is selected)
75+ - ` npm run lint ` - Run linting (if style plugin is selected)
76+
77+ ### MCP Client
78+
79+ Create an MCP client that connects to MCP servers and uses their tools, resources, and prompts.
80+
81+ #### Client Project Structure
82+
83+ ``` text
84+ The generated client project will have the following structure:
85+
86+ ├── src/
87+ │ └── index.ts # Entry point with transport implementations
88+ ├── tests/ # Test files (optional)
4689├── scripts/ # Build and development scripts
47- ├── .github/ # GitHub Actions workflows
90+ ├── .github/ # GitHub Actions workflows (optional)
91+ ├── .husky/ # Git hooks (optional)
4892└── package.json
4993```
5094
51- ## Development Scripts
95+ #### Client Development Scripts
5296
53- - npm run dev - Start the development server in stdio mode
54- - npm run dev : web - Start the development server in web mode
55- - npm run build - Build the project
56- - npm run test - Run tests
57- - npm run coverage - Generate test coverage report
97+ - ` npm run dev ` - Start the client in development mode
98+ - ` npm run build ` - Build the project
99+ - ` npm run test ` - Run tests (if vitest plugin is selected)
100+ - ` npm run coverage ` - Generate test coverage report (if vitest plugin is selected)
101+ - ` npm run lint ` - Run linting (if style plugin is selected)
58102
59103## Features
60- ### MCP Tools
104+
105+ ### MCP Server Features
106+
107+ #### Transport Modes
108+
109+ MCP Server supports three transport modes:
110+
111+ 1 . ** STDIO** : Communication through standard input/output streams
112+ 2 . ** Streamable HTTP** : RESTful API with streaming capabilities
113+ 3 . ** SSE (Server-Sent Events)** : Real-time event streaming from server to client
114+
115+ #### MCP Tools
61116Implement custom tools that can be used by MCP clients:
62117
63118``` ts
64- server .registerTool (
65- ' GetData' ,
66- {
67- title: ' Get Data' ,
68- description: ' Get Data' ,
69- inputSchema: {
70- keyword: z .string ().describe (' search keyword' ),
119+ // Full implementation example
120+ import { z } from ' zod'
121+ import type { McpServer } from ' @modelcontextprotocol/sdk/server/mcp.js'
122+
123+ export default function register(server , options ) {
124+ server .registerTool (
125+ ' GetData' ,
126+ {
127+ title: ' Get Data' ,
128+ description: ' Get Data' ,
129+ inputSchema: {
130+ keyword: z .string ().describe (' search keyword' ),
131+ },
71132 },
72- },
73- async ({ keyword }) => {
74- // Your implementation
133+ async ({ keyword }) => {
134+ const { success, data, message } = await getData (keyword , options )
135+ return {
136+ content: [
137+ {
138+ type: ' text' ,
139+ text: success ? data : message ,
140+ },
141+ ],
142+ }
143+ },
144+ )
145+ }
146+
147+ export const getData = async (keyword , options ) => {
148+ if (! keyword || keyword === ' error' ) {
149+ return {
150+ success: false ,
151+ message: ' Invalid keyword' ,
152+ }
153+ }
154+
155+ return {
156+ success: true ,
157+ data: ` Data for ${keyword } ` ,
75158 }
76- )
159+ }
77160```
78- ### MCP Resources
161+
162+ #### MCP Resources
79163Define resources that can be accessed by MCP clients:
80164
81165``` ts
82- server .registerResource (
83- ' search' ,
84- new ResourceTemplate (' search://{keyword}' , {
85- list: undefined ,
86- }),
87- {
88- title: ' Search Resource' ,
89- description: ' Dynamic generate search resource' ,
90- },
91- async (uri , { keyword }) => {
92- // Your implementation
93- }
94- )
166+ // Full implementation example
167+ import { type McpServer , ResourceTemplate } from ' @modelcontextprotocol/sdk/server/mcp.js'
168+ import type { OptionsType } from ' @/types'
169+
170+ export const registerResources = (server : McpServer , options : OptionsType ) => {
171+ server .registerResource (
172+ ' search' ,
173+ new ResourceTemplate (' search://{keyword}' , {
174+ list: undefined ,
175+ }),
176+ {
177+ title: ' Search Resource' ,
178+ description: ' Dynamic generate search resource' ,
179+ },
180+ async (uri , { keyword }) => {
181+ return {
182+ contents: [
183+ {
184+ uri: uri .href ,
185+ text: ` search ${keyword } ` ,
186+ },
187+ ],
188+ }
189+ },
190+ )
191+ }
95192```
96- ### MCP Prompts
193+
194+ #### MCP Prompts
97195Create reusable prompts for MCP clients:
98196
99197``` ts
100- server .registerPrompt (
101- ' echo' ,
102- {
103- title: ' Echo Prompt' ,
104- description: ' Creates a prompt to process a message.' ,
105- argsSchema: {
106- message: z .string (),
198+ // Full implementation example
199+ import { z } from ' zod'
200+ import type { McpServer } from ' @modelcontextprotocol/sdk/server/mcp.js'
201+
202+ export const registerPrompts = (server : McpServer ) => {
203+ server .registerPrompt (
204+ ' echo' ,
205+ {
206+ title: ' Echo Prompt' ,
207+ description: ' Creates a prompt to process a message.' ,
208+ argsSchema: {
209+ message: z .string (),
210+ },
107211 },
212+ ({ message }) => {
213+ return {
214+ messages: [
215+ {
216+ role: ' user' ,
217+ content: {
218+ type: ' text' ,
219+ text: ` Please process this message: ${message } ` ,
220+ },
221+ },
222+ ],
223+ }
224+ },
225+ )
226+ }
227+ ```
228+
229+ ### MCP Client Features
230+
231+ #### Multiple Transport Modes
232+ Connect to MCP servers using different transport modes:
233+
234+ ``` ts
235+ // Import the MCP client
236+ import { McpClient } from ' @modelcontextprotocol/sdk/client/mcp.js'
237+ import { StdioClientTransport } from ' @modelcontextprotocol/sdk/client/transports/stdio.js'
238+ import { StreamableHTTPClientTransport } from ' @modelcontextprotocol/sdk/client/transports/streamable-http.js'
239+ import { SSEClientTransport } from ' @modelcontextprotocol/sdk/client/transports/sse.js'
240+
241+ // Create a new MCP client
242+ const client = new McpClient ()
243+
244+ // STDIO Transport
245+ const stdioClientTransport = new StdioClientTransport ({
246+ command: ' npx' ,
247+ args: [' -y' , ' @my-mcp-hub/node-mcp-server' ],
248+ env: process .env ,
249+ })
250+ await client .connect (stdioClientTransport )
251+
252+ // Streamable HTTP Transport
253+ const streamableBaseUrl = new URL (' http://localhost:8401/mcp' )
254+ const streamableClientTransport = new StreamableHTTPClientTransport (streamableBaseUrl )
255+ await client .connect (streamableClientTransport )
256+
257+ // SSE Transport
258+ const sseBaseUrl = new URL (' http://localhost:8401/sse' )
259+ const sseClientTransport = new SSEClientTransport (sseBaseUrl )
260+ await client .connect (sseClientTransport )
261+ ```
262+
263+ #### Tool Calling
264+ Call tools provided by MCP servers:
265+
266+ ``` ts
267+ // List available tools
268+ const tools = await client .listTools ()
269+ console .log (tools )
270+
271+ // Call a tool
272+ const callResult = await client .callTool ({
273+ name: ' GetData' ,
274+ arguments: {
275+ keyword: ' Hello' ,
108276 },
109- ({ message }) => {
110- // Your implementation
111- }
112- )
277+ })
278+ console .log (callResult .content )
279+ ```
280+
281+ #### Resource Access
282+ Access resources provided by MCP servers:
283+
284+ ``` ts
285+ // List available resources
286+ const resources = await client .listResources ()
287+ console .log (resources )
288+
289+ // Get a resource
290+ const resource = await client .getResource (' search://example' )
291+ console .log (resource .contents )
292+ ```
293+
294+ #### Prompt Usage
295+ Use prompts provided by MCP servers:
296+
297+ ``` ts
298+ // List available prompts
299+ const prompts = await client .listPrompts ()
300+ console .log (prompts )
301+
302+ // Use a prompt
303+ const prompt = await client .getPrompt (' echo' , { message: ' Hello, world!' })
304+ console .log (prompt .messages )
113305```
114306
115307## Contributing
0 commit comments