@@ -29,3 +29,86 @@ Servers offer any of the following features to clients:
2929Resources: Context and data, for the user or the AI model to use
3030Prompts: Templated messages and workflows for users
3131Tools: 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>
0 commit comments