-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample-complete.ts
64 lines (57 loc) · 1.33 KB
/
example-complete.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
import EasyMCP from "./lib/EasyMCP";
const mcp = EasyMCP.create("test-mcp", {
version: "0.1.0",
});
mcp.resource({
uri: "dir://desktop",
name: "An optional name",
description: "An optional description",
mimeType: "text/plain", // optional
fn: async () => {
return "file://desktop/file1.txt";
},
});
mcp.template({
uriTemplate: "file://{parameter1}/{parameter2}",
name: "An optional name",
description: "An optional description",
mimeType: "text/plain", // Optional
fn: async ({ filename }) => {
return `file://${filename}/file1.txt`;
},
});
mcp.tool({
name: "hello world",
inputs: [
{
name: "optionalInput",
type: "string",
description: "an optional input",
required: false,
},
],
fn: async ({ name }) => {
return `Hello, ${name}!`;
},
});
mcp.prompt({
name: "Hello World Prompt",
description: "A prompt that says hello",
// TODO: find a way to infer the args from the parameters input to fn below, so we don't have to explicitly define them here.
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);