Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save maskaravivek/3cbb8acda140d62fd8ea8f17c106fa34 to your computer and use it in GitHub Desktop.

Select an option

Save maskaravivek/3cbb8acda140d62fd8ea8f17c106fa34 to your computer and use it in GitHub Desktop.
import { Server } from "@modelcontextprotocol/server";
import { stdioServer } from "@modelcontextprotocol/server/stdio";
import { TextContent } from "@modelcontextprotocol/types";
async function serve() {
const server = new Server("refund-agent");
// Advertise available tools
server.listTools(async () => [
{
name: "refund-payment",
description: "Process a refund for a given order.",
inputSchema: {
type: "object",
properties: {
order_id: {
type: "string",
description: "The order ID to refund."
}
},
required: ["order_id"],
},
},
]);
// Handle tool calls
server.callTool(async (name, args) => {
const { order_id } = args;
// Real refund logic would go here
return [
new TextContent({
text: `Refund initiated for order ${order_id}.`
}),
];
});
const options = server.createInitializationOptions();
const { read, write } = stdioServer();
await server.run(read, write, options);
}
serve();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment