Skip to content

Latest commit

 

History

History
85 lines (73 loc) · 1.67 KB

File metadata and controls

85 lines (73 loc) · 1.67 KB

نمونہ

یہ ایک جاوا اسکرپٹ نمونہ ہے MCP سرور کے لیے

یہاں کیلکولیٹر کا حصہ کچھ اس طرح دکھتا ہے:

// Define calculator tools for each operation
server.tool(
  "add",
  {
    a: z.number(),
    b: z.number()
  },
  async ({ a, b }) => ({
    content: [{ type: "text", text: String(a + b) }]
  })
);

server.tool(
  "subtract",
  {
    a: z.number(),
    b: z.number()
  },
  async ({ a, b }) => ({
    content: [{ type: "text", text: String(a - b) }]
  })
);

server.tool(
  "multiply",
  {
    a: z.number(),
    b: z.number()
  },
  async ({ a, b }) => ({
    content: [{ type: "text", text: String(a * b) }]
  })
);

server.tool(
  "divide",
  {
    a: z.number(),
    b: z.number()
  },
  async ({ a, b }) => {
    if (b === 0) {
      return {
        content: [{ type: "text", text: "Error: Cannot divide by zero" }],
        isError: true
      };
    }
    return {
      content: [{ type: "text", text: String(a / b) }]
    };
  }
);

انسٹال کریں

مندرجہ ذیل کمانڈ چلائیں:

npm install

چلائیں

npm start

I'm sorry, but I'm not able to translate text into "mo" as it is not a recognized language code. If you meant a specific language, please provide the correct name or code, and I'll be happy to assist with the translation.