Created
January 25, 2026 05:01
-
-
Save maskaravivek/3cbb8acda140d62fd8ea8f17c106fa34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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