Skip to content

Commit 1a0782c

Browse files
committed
chore: update dependencies
1 parent 2b5aff4 commit 1a0782c

File tree

7 files changed

+863
-281
lines changed

7 files changed

+863
-281
lines changed

.changeset/sharp-guests-tell.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'create-mcp-kit': patch
3+
'@mcp-tool-kit/shared': patch
4+
---
5+
6+
chore: update dependencies

README.md

Lines changed: 241 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -31,85 +33,275 @@ or
3133
pnpm 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
61116
Implement 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
79163
Define 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
97195
Create 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

docs/en/guide/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The generated file structure depends on the project type you selected.
8787
│ │ ├── stdio.ts # STDIO transport implementation
8888
│ │ └── web.ts # Streamable HTTP and SSE transport implementation
8989
│ └── index.ts # Entry point
90-
├── tests/ # Test files
90+
├── tests/ # Test files (optional)
9191
├── scripts/ # Build and development scripts
9292
├── .github/ # GitHub Actions workflows (optional)
9393
├── .husky/ # Git hooks (optional)
@@ -99,7 +99,7 @@ The generated file structure depends on the project type you selected.
9999
```
100100
├── src/
101101
│ └── index.ts # Entry point with transport implementations
102-
├── tests/ # Test files
102+
├── tests/ # Test files (optional)
103103
├── scripts/ # Build and development scripts
104104
├── .github/ # GitHub Actions workflows (optional)
105105
├── .husky/ # Git hooks (optional)

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
"@rollup/plugin-terser": "^0.4.4",
4949
"@rollup/plugin-typescript": "^12.1.4",
5050
"@types/node": "22",
51-
"@typescript-eslint/eslint-plugin": "^8.40.0",
52-
"@typescript-eslint/parser": "^8.40.0",
51+
"@typescript-eslint/eslint-plugin": "^8.41.0",
52+
"@typescript-eslint/parser": "^8.41.0",
5353
"@vitest/coverage-v8": "^3.2.4",
5454
"c8": "^10.1.3",
5555
"cross-env": "^10.0.0",
56-
"eslint": "^9.33.0",
56+
"eslint": "^9.34.0",
5757
"eslint-plugin-import": "^2.32.0",
5858
"eslint-plugin-prettier": "^5.5.4",
5959
"execa": "^9.6.0",
@@ -63,7 +63,7 @@
6363
"prettier": "^3.6.2",
6464
"rimraf": "^6.0.1",
6565
"rolldown": "1.0.0-beta.27",
66-
"tsx": "^4.20.4",
66+
"tsx": "^4.20.5",
6767
"typescript": "^5.9.2",
6868
"vitest": "^3.2.4"
6969
}

0 commit comments

Comments
 (0)