# דוגמה זו דוגמת JavaScript עבור שרת MCP כך נראה החלק של המכונה החישובית: ```javascript // 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) }] }; } ); ``` ## התקנה הרץ את הפקודה הבאה: ```bash npm install ``` ## הפעלה ```bash npm start ``` **כתב ויתור**: מסמך זה תורגם באמצעות שירות תרגום מבוסס בינה מלאכותית [Co-op Translator](https://github.com/Azure/co-op-translator). למרות שאנו שואפים לדיוק, יש לקחת בחשבון כי תרגומים אוטומטיים עלולים להכיל שגיאות או אי-דיוקים. המסמך המקורי בשפת המקור שלו נחשב למקור הסמכותי. למידע קריטי מומלץ להשתמש בתרגום מקצועי על ידי מתרגם אנושי. אנו לא נושאים באחריות לכל אי-הבנה או פרשנות שגויה הנובעת משימוש בתרגום זה.