@ashwinhprasad10/simple-mcp-server-ashwin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/index.ts +77 -0
- package/package.json +27 -0
- package/tsconfig.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Simple MCP Server — official TypeScript SDK (v1)
|
|
4
|
+
*
|
|
5
|
+
* Tools:
|
|
6
|
+
* 1. echo – Returns whatever text you send
|
|
7
|
+
* 2. add – Adds two numbers
|
|
8
|
+
* 3. get_datetime – Returns the current ISO timestamp
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Simple MCP Server — official TypeScript SDK (v1)
|
|
4
|
+
*
|
|
5
|
+
* Tools:
|
|
6
|
+
* 1. echo – Returns whatever text you send
|
|
7
|
+
* 2. add – Adds two numbers
|
|
8
|
+
* 3. get_datetime – Returns the current ISO timestamp
|
|
9
|
+
*/
|
|
10
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
// ─── Create server ────────────────────────────────────────────────────────────
|
|
14
|
+
const server = new McpServer({
|
|
15
|
+
name: "simple-mcp-server",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
});
|
|
18
|
+
// ─── Register tools ───────────────────────────────────────────────────────────
|
|
19
|
+
server.registerTool("echo", {
|
|
20
|
+
title: "Echo",
|
|
21
|
+
description: "Returns the exact text you provide. Useful for testing.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
text: z.string().describe("The text to echo back."),
|
|
24
|
+
},
|
|
25
|
+
}, async ({ text }) => ({
|
|
26
|
+
content: [{ type: "text", text: `Echo: ${text}` }],
|
|
27
|
+
}));
|
|
28
|
+
server.registerTool("add", {
|
|
29
|
+
title: "Add",
|
|
30
|
+
description: "Adds two numbers and returns the result.",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
a: z.number().describe("First number."),
|
|
33
|
+
b: z.number().describe("Second number."),
|
|
34
|
+
},
|
|
35
|
+
}, async ({ a, b }) => ({
|
|
36
|
+
content: [{ type: "text", text: `${a} + ${b} = ${a + b}` }],
|
|
37
|
+
}));
|
|
38
|
+
server.registerTool("get_datetime", {
|
|
39
|
+
title: "Get Date & Time",
|
|
40
|
+
description: "Returns the current date and time in ISO 8601 format.",
|
|
41
|
+
inputSchema: {},
|
|
42
|
+
}, async () => ({
|
|
43
|
+
content: [{ type: "text", text: new Date().toISOString() }],
|
|
44
|
+
}));
|
|
45
|
+
// ─── Connect and start ────────────────────────────────────────────────────────
|
|
46
|
+
async function main() {
|
|
47
|
+
const transport = new StdioServerTransport();
|
|
48
|
+
await server.connect(transport);
|
|
49
|
+
console.error("MCP server running on stdio");
|
|
50
|
+
}
|
|
51
|
+
main().catch((err) => {
|
|
52
|
+
console.error("Fatal error:", err);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EA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CAAC;IACX,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;CAC5D,CAAC,CACH,CAAC;AAEF,iFAAiF;AAEjF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Simple MCP Server — official TypeScript SDK (v1)
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* 1. echo – Returns whatever text you send
|
|
8
|
+
* 2. add – Adds two numbers
|
|
9
|
+
* 3. get_datetime – Returns the current ISO timestamp
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
|
|
16
|
+
// ─── Create server ────────────────────────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
const server = new McpServer({
|
|
19
|
+
name: "simple-mcp-server",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// ─── Register tools ───────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
server.registerTool(
|
|
26
|
+
"echo",
|
|
27
|
+
{
|
|
28
|
+
title: "Echo",
|
|
29
|
+
description: "Returns the exact text you provide. Useful for testing.",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
text: z.string().describe("The text to echo back."),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
async ({ text }) => ({
|
|
35
|
+
content: [{ type: "text", text: `Echo: ${text}` }],
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
server.registerTool(
|
|
40
|
+
"add",
|
|
41
|
+
{
|
|
42
|
+
title: "Add",
|
|
43
|
+
description: "Adds two numbers and returns the result.",
|
|
44
|
+
inputSchema: {
|
|
45
|
+
a: z.number().describe("First number."),
|
|
46
|
+
b: z.number().describe("Second number."),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
async ({ a, b }) => ({
|
|
50
|
+
content: [{ type: "text", text: `${a} + ${b} = ${a + b}` }],
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
server.registerTool(
|
|
55
|
+
"get_datetime",
|
|
56
|
+
{
|
|
57
|
+
title: "Get Date & Time",
|
|
58
|
+
description: "Returns the current date and time in ISO 8601 format.",
|
|
59
|
+
inputSchema: {},
|
|
60
|
+
},
|
|
61
|
+
async () => ({
|
|
62
|
+
content: [{ type: "text", text: new Date().toISOString() }],
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// ─── Connect and start ────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
async function main() {
|
|
69
|
+
const transport = new StdioServerTransport();
|
|
70
|
+
await server.connect(transport);
|
|
71
|
+
console.error("MCP server running on stdio");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main().catch((err) => {
|
|
75
|
+
console.error("Fatal error:", err);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ashwinhprasad10/simple-mcp-server-ashwin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A minimal MCP server using the official TypeScript SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"simple-mcp-server": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"dev": "tsx src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
17
|
+
"zod": "^3.25.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^20.19.43",
|
|
21
|
+
"tsx": "^4.0.0",
|
|
22
|
+
"typescript": "^5.3.0"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
// "rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"types": ["node"],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
// "noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"strict": true,
|
|
37
|
+
"jsx": "react-jsx",
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"isolatedModules": true,
|
|
40
|
+
"noUncheckedSideEffectImports": true,
|
|
41
|
+
"moduleDetection": "force",
|
|
42
|
+
"skipLibCheck": true,
|
|
43
|
+
}
|
|
44
|
+
}
|