Skip to content

Commit 0b02331

Browse files
authored
Merge pull request #86 from QuantGeekDev/feature/migrate-http-transport
Feature/migrate http transport
2 parents b6de268 + 1b5b8e7 commit 0b02331

File tree

7 files changed

+518
-1162
lines changed

7 files changed

+518
-1162
lines changed

.cursor/rules/mcp-framework.mdc

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,86 @@ Servers offer any of the following features to clients:
2929
Resources: Context and data, for the user or the AI model to use
3030
Prompts: Templated messages and workflows for users
3131
Tools: Functions for the AI model to execute</specification>
32+
33+
Here is an example of how a user creats an mcp server using mcp-framework as the library: <example>## src/tools/ExampleTool.ts
34+
35+
```ts
36+
import { MCPTool } from "mcp-framework";
37+
import { z } from "zod";
38+
39+
interface ExampleInput {
40+
message: string;
41+
}
42+
43+
class ExampleTool extends MCPTool<ExampleInput> {
44+
name = "example_tool";
45+
description = "An example tool that processes messages";
46+
47+
schema = {
48+
message: {
49+
type: z.string(),
50+
description: "Message to process",
51+
},
52+
};
53+
54+
async execute(input: ExampleInput) {
55+
return `Processed: ${input.message}`;
56+
}
57+
}
58+
59+
export default ExampleTool;
60+
```
61+
62+
## src/index.ts
63+
64+
```ts
65+
import { MCPServer } from "mcp-framework";
66+
67+
const server = new MCPServer({transport:{
68+
type:"http-stream",
69+
options:{
70+
port:1337,
71+
cors: {
72+
allowOrigin:"*"
73+
}
74+
}
75+
}});
76+
77+
server.start();
78+
79+
```
80+
81+
## package.json
82+
83+
```json
84+
{
85+
"name": "http2-hi",
86+
"version": "0.0.1",
87+
"description": "http2-hi MCP server",
88+
"type": "module",
89+
"bin": {
90+
"http2-hi": "./dist/index.js"
91+
},
92+
"files": [
93+
"dist"
94+
],
95+
"scripts": {
96+
"build": "tsc && mcp-build",
97+
"watch": "tsc --watch",
98+
"start": "node dist/index.js"
99+
},
100+
"dependencies": {
101+
"mcp-framework": "^0.2.12-beta.4",
102+
"zod": "^3.24.4"
103+
},
104+
"devDependencies": {
105+
"@types/node": "^20.11.24",
106+
"typescript": "^5.3.3"
107+
},
108+
"engines": {
109+
"node": ">=18.19.0"
110+
}
111+
}
112+
113+
```
114+
</example>

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ README
55
.DS_Store
66
dist
77
node_modules
8-
.cursor

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"watch": "tsc --watch",
2525
"lint": "eslint",
2626
"lint:fix": "eslint --fix",
27-
"format": "prettier --write \"src/**/*.ts\""
27+
"format": "prettier --write \"src/**/*.ts\"",
28+
"dev:pub": "rm -rf dist && npm run build && yalc publish --push"
2829
},
2930
"engines": {
3031
"node": ">=18.19.0"
@@ -42,7 +43,7 @@
4243
"protocol"
4344
],
4445
"peerDependencies": {
45-
"@modelcontextprotocol/sdk": "1.8"
46+
"@modelcontextprotocol/sdk": "^1.11.0"
4647
},
4748
"dependencies": {
4849
"@types/prompts": "^2.4.9",

0 commit comments

Comments
 (0)