fastmcp 1.22.4 → 1.23.1

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.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { execa } from "execa";
3
4
  import yargs from "yargs";
4
5
  import { hideBin } from "yargs/helpers";
5
- import { execa } from "execa";
6
6
 
7
7
  await yargs(hideBin(process.argv))
8
8
  .scriptName("fastmcp")
@@ -11,17 +11,17 @@ await yargs(hideBin(process.argv))
11
11
  "Start a development server",
12
12
  (yargs) => {
13
13
  return yargs.positional("file", {
14
- type: "string",
15
- describe: "The path to the server file",
16
14
  demandOption: true,
15
+ describe: "The path to the server file",
16
+ type: "string",
17
17
  });
18
18
  },
19
19
  async (argv) => {
20
20
  try {
21
21
  await execa({
22
+ stderr: "inherit",
22
23
  stdin: "inherit",
23
24
  stdout: "inherit",
24
- stderr: "inherit",
25
25
  })`npx @wong2/mcp-cli npx tsx ${argv.file}`;
26
26
  } catch {
27
27
  process.exit(1);
@@ -33,16 +33,16 @@ await yargs(hideBin(process.argv))
33
33
  "Inspect a server file",
34
34
  (yargs) => {
35
35
  return yargs.positional("file", {
36
- type: "string",
37
- describe: "The path to the server file",
38
36
  demandOption: true,
37
+ describe: "The path to the server file",
38
+ type: "string",
39
39
  });
40
40
  },
41
41
  async (argv) => {
42
42
  try {
43
43
  await execa({
44
- stdout: "inherit",
45
44
  stderr: "inherit",
45
+ stdout: "inherit",
46
46
  })`npx @modelcontextprotocol/inspector npx tsx ${argv.file}`;
47
47
  } catch {
48
48
  process.exit(1);
@@ -1,10 +1,11 @@
1
+ import { type } from "arktype";
2
+ import * as v from "valibot";
3
+ import { z } from "zod";
4
+
1
5
  /**
2
6
  * This is a complete example of an MCP server.
3
7
  */
4
8
  import { FastMCP } from "../FastMCP.js";
5
- import { z } from "zod";
6
- import { type } from "arktype";
7
- import * as v from "valibot";
8
9
 
9
10
  const server = new FastMCP({
10
11
  name: "Addition",
@@ -18,14 +19,19 @@ const AddParamsZod = z.object({
18
19
  });
19
20
 
20
21
  server.addTool({
21
- name: "add-zod",
22
+ annotations: {
23
+ openWorldHint: false, // This tool doesn't interact with external systems
24
+ readOnlyHint: true, // This tool doesn't modify anything
25
+ title: "Addition (Zod)",
26
+ },
22
27
  description: "Add two numbers (using Zod schema)",
23
- parameters: AddParamsZod,
24
28
  execute: async (args) => {
25
29
  // args is typed as { a: number, b: number }
26
30
  console.log(`[Zod] Adding ${args.a} and ${args.b}`);
27
31
  return String(args.a + args.b);
28
32
  },
33
+ name: "add-zod",
34
+ parameters: AddParamsZod,
29
35
  });
30
36
 
31
37
  // --- ArkType Example ---
@@ -35,14 +41,21 @@ const AddParamsArkType = type({
35
41
  });
36
42
 
37
43
  server.addTool({
38
- name: "add-arktype",
44
+ annotations: {
45
+ destructiveHint: true, // This would perform destructive operations
46
+ idempotentHint: true, // But operations can be repeated safely
47
+ openWorldHint: true, // Interacts with external systems
48
+ readOnlyHint: false, // Example showing a modifying tool
49
+ title: "Addition (ArkType)",
50
+ },
39
51
  description: "Add two numbers (using ArkType schema)",
40
- parameters: AddParamsArkType,
41
52
  execute: async (args) => {
42
53
  // args is typed as { a: number, b: number } based on AddParamsArkType.infer
43
54
  console.log(`[ArkType] Adding ${args.a} and ${args.b}`);
44
55
  return String(args.a + args.b);
45
56
  },
57
+ name: "add-arktype",
58
+ parameters: AddParamsArkType,
46
59
  });
47
60
 
48
61
  // --- Valibot Example ---
@@ -52,39 +65,44 @@ const AddParamsValibot = v.object({
52
65
  });
53
66
 
54
67
  server.addTool({
55
- name: "add-valibot",
68
+ annotations: {
69
+ openWorldHint: false,
70
+ readOnlyHint: true,
71
+ title: "Addition (Valibot)",
72
+ },
56
73
  description: "Add two numbers (using Valibot schema)",
57
- parameters: AddParamsValibot,
58
74
  execute: async (args) => {
59
75
  console.log(`[Valibot] Adding ${args.a} and ${args.b}`);
60
76
  return String(args.a + args.b);
61
77
  },
78
+ name: "add-valibot",
79
+ parameters: AddParamsValibot,
62
80
  });
63
81
 
64
82
  server.addResource({
65
- uri: "file:///logs/app.log",
66
- name: "Application Logs",
67
- mimeType: "text/plain",
68
83
  async load() {
69
84
  return {
70
85
  text: "Example log content",
71
86
  };
72
87
  },
88
+ mimeType: "text/plain",
89
+ name: "Application Logs",
90
+ uri: "file:///logs/app.log",
73
91
  });
74
92
 
75
93
  server.addPrompt({
76
- name: "git-commit",
77
- description: "Generate a Git commit message",
78
94
  arguments: [
79
95
  {
80
- name: "changes",
81
96
  description: "Git diff or description of changes",
97
+ name: "changes",
82
98
  required: true,
83
99
  },
84
100
  ],
101
+ description: "Generate a Git commit message",
85
102
  load: async (args) => {
86
103
  return `Generate a concise but descriptive commit message for these changes:\n\n${args.changes}`;
87
104
  },
105
+ name: "git-commit",
88
106
  });
89
107
 
90
108
  server.start({
package/eslint.config.js DELETED
@@ -1,3 +0,0 @@
1
- import perfectionist from "eslint-plugin-perfectionist";
2
-
3
- export default [perfectionist.configs["recommended-alphabetical"]];