-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
72 lines (64 loc) · 1.5 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import BaseMCP from "./lib/EasyMCP";
const mcp = BaseMCP.create("test-mcp", {
version: "0.1.0",
});
mcp.resource({
uri: "dir://desktop",
name: "An optional name", // Optional
description: "An optional description", // Optional
mimeType: "text/plain", // optional
fn: async () => {
return "file://desktop/file1.txt";
},
});
mcp.template({
uriTemplate: "file://{filename}/{id}",
name: "An optional name", // Optional
description: "An optional description", // Optional
mimeType: "text/plain", // Optional
fn: addMetadata(
async ({ filename, id }: { filename: string; id: string }) => {
return `file://${filename}/${id}.txt`;
},
),
});
function addMetadata(fn: Function) {
return function (...args: any[]) {
// Here you can add logic to parse the function and add metadata
return fn(...args);
};
}
mcp.tool({
name: "hello world",
inputs: [
{
name: "optionalInput",
type: "string",
description: "an optional input",
required: false,
},
],
fn: async ({ optionalInput }) => {
return `Hello, ${optionalInput}!`;
},
});
mcp.prompt({
name: "Hello World Prompt",
description: "A prompt that says hello",
args: [
{
name: "name",
type: "string",
description: "Your name",
required: true,
},
],
fn: async ({ name }: { name: string }) => {
return `Hello, ${name}!`;
},
});
mcp.root({
name: "Optional Name",
uri: "/Users/username/Desktop",
});
await mcp.serve().catch(console.error);