### Local Development Setup Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Commands to set up the project for local development. This includes installing dependencies, copying the environment example, and starting the development server. ```bash npm install cp .env.example .env # Edit .env with your token npm run dev ``` -------------------------------- ### Environment Variable Setup Steps Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Outlines the steps to configure environment variables, including copying the example file, adding tokens, and setting up Gmail OAuth. ```text 1. Copy .env.example to .env 2. Add AI_SECRET_TOKEN value 3. For Gmail: run npm run setup to generate tokens 4. For Gmail: add GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET 5. Optionally set TIMEZONE, STORE_NAME, PORT 6. Start with npm start or npm run dev ``` -------------------------------- ### Execute Setup Script Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Initiates the OAuth setup process by running the setup script using npm. This command triggers the sequence of steps outlined in the documentation. ```bash npm run setup ``` -------------------------------- ### npm Scripts for Development and Production Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Provides commands for starting the MCP server in development or production, running the OAuth setup, and executing the Gmail worker. ```bash npm start # Start MCP server npm run dev # Start with watch npm run setup # Interactive OAuth setup npm run worker # Fetch and report on emails ``` -------------------------------- ### Install Dependencies Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/README.md Installs project dependencies using npm. Ensure you have Node.js and npm installed. ```bash npm install ``` -------------------------------- ### External Dependencies for Setup Script Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md These are the external Node.js modules required by the setup-gmail-oauth.js script. Ensure these are installed via npm. ```javascript import 'dotenv/config'; import { google } from 'googleapis'; import readline from 'readline'; import fs from 'fs'; ``` -------------------------------- ### Configure Environment Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/README.md Copies the example environment file and prompts to edit it. Remember to add your AI_SECRET_TOKEN. ```bash cp .env.example .env # Edit .env and add your AI_SECRET_TOKEN ``` -------------------------------- ### Example .env File for MCP Server Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md This is an example of the .env file used for configuring the MCP Server. It includes required and optional environment variables. ```bash # MCP Server Configuration PORT=3334 AI_SECRET_TOKEN=your-secret-token-here # Optional for production # RAILWAY_PUBLIC_DOMAIN=your-app.up.railway.app ``` -------------------------------- ### Setup Gmail OAuth Utility Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Commands to run the interactive OAuth setup utility for Gmail authentication. This process generates necessary credentials for accessing the Gmail API. ```bash npm run setup node setup-gmail-oauth.js ``` -------------------------------- ### Example .env Addition for Gmail Worker Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md This example shows how to add Gmail-specific configurations to the .env file. It includes OAuth credentials and timezone settings. ```bash # Gmail Configuration GOOGLE_CLIENT_ID=YOUR_CLIENT_ID.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=YOUR_CLIENT_SECRET TIMEZONE=America/Detroit STORE_NAME=MyStore GOOGLE_REDIRECT=http://localhost:3000/oauth2/callback ``` -------------------------------- ### Example of Extracting Authorization Code Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Demonstrates how to use the URL object to get the 'code' query parameter from a redirect URL string. ```javascript const redirectUrl = 'http://localhost:3000/oauth2/callback?code=4%2F0AVG5wmRu'; const urlObj = new URL(redirectUrl); const code = urlObj.searchParams.get('code'); // code = '4/0AVG5wmRu' ``` -------------------------------- ### package.json Configuration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md The package.json file defines project metadata, scripts, and dependencies. Key fields include 'type' set to 'module' for ES module support and 'scripts' for common commands like start, dev, and setup. ```json { "name": "ops-mcp-server", "version": "1.0.0", "type": "module", "main": "server.js", "scripts": { "start": "node server.js", "dev": "nodemon server.js", "setup": "node setup-gmail-oauth.js", "worker": "node worker.js" }, "dependencies": { "@modelcontextprotocol/sdk": "^1.0.0", "dayjs": "^1.11.10", "dotenv": "^16.3.1", "googleapis": "^128.0.0", "nanoid": "^5.0.3", "node-fetch": "^3.3.2", "nodemon": "^3.0.1", "readline": "^1.3.0", "ws": "^8.14.0" }, "engines": { "node": ">=18.0.0" } } ``` -------------------------------- ### Mark Task Done Success Response Example Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md An example of a successful response from the `mark_task_done` tool, confirming the task completion. ```json { "content": [{ "type": "text", "text": "āœ… Task abc123 marked complete" }] } ``` -------------------------------- ### Fetch Ops Report Example Success Response Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This JSON example shows a successful response from the fetch_ops_report tool, including formatted report content. ```json { "content": [{ "type": "text", "text": "# Talked to Gmail\n\n## āœ… No 911 Issues\nNo call-offs in last 12 hours\n\n## šŸ“… Deadlines & Deliverables\n2 items requiring attention\n\n## Full Report\nSchedule due Friday, EOP submission needed" }] } ``` -------------------------------- ### QueryConfig Example Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/types.md An example of a QueryConfig object used for searching Gmail. Demonstrates how to specify search criteria and classification type. ```typescript { query: 'newer_than:12h from:*@hotschedules.com OR subject:"called off"', window: 12, type: '911' } ``` -------------------------------- ### Local Development with Gmail Integration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Commands to set up and run the project locally, including Gmail integration. This involves authorizing with Google, running the worker, and starting the MCP server. ```bash npm run setup # Authorize with Google npm run worker # Test Gmail integration npm run dev # Start MCP server ``` -------------------------------- ### ToolCallResponse Examples Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/types.md Provides examples of successful and error responses from tool executions. ```typescript { content: [{ type: 'text', text: '# Talked to Gmail\n\n## āœ… No 911 Issues\n...' }] } ``` ```typescript { content: [{ type: 'text', text: 'Error: Task ID required' }], isError: true } ``` -------------------------------- ### Run Server Locally Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/README.md Starts the MCP server locally. The server will be accessible at ws://localhost:3334. ```bash npm start # Server runs on ws://localhost:3334 ``` -------------------------------- ### Fetch Ops Report Example Error Response Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This JSON example demonstrates an error response from the fetch_ops_report tool, indicating an API failure. ```json { "content": [{ "type": "text", "text": "Error: API returned 401" }], "isError": true } ``` -------------------------------- ### Run MCP Server Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Commands to start the MCP server in production or development mode using npm scripts. ```bash npm start # Production mode npm run dev # Development with watch ``` -------------------------------- ### OAuth2 Client Setup with Error Handling Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Illustrates the core logic for obtaining OAuth tokens, including URL parsing, code validation, token exchange, and comprehensive error handling using a try-catch block. ```javascript try { const urlObj = new URL(url); const code = urlObj.searchParams.get('code'); if (!code) { throw new Error('No code found in URL'); } const { tokens } = await oAuth2Client.getToken(code); // ... save tokens ... console.log('\nāœ… Success! ...'); } catch (error) { console.error('\nāŒ Error:', error.message); } ``` -------------------------------- ### ToolCallRequest Examples Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/types.md Illustrates how to structure ToolCallRequests for different tools, including 'fetch_ops_report' and 'mark_task_done'. ```typescript // fetch_ops_report call { params: { name: 'fetch_ops_report', arguments: {} } } ``` ```typescript // mark_task_done call { params: { name: 'mark_task_done', arguments: { id: 'xyz123' } } } ``` -------------------------------- ### Fetch Ops Report Backend Request Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This HTTP request example shows how the ops-mcp-server calls the backend API to fetch operations data. ```http POST /api/ops/fetch HTTP/1.1 Authorization: Bearer {AI_SECRET_TOKEN} Content-Type: application/json ``` -------------------------------- ### Mark Task Done Error Response Example (Missing ID) Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md An example of an error response when the `id` argument is missing for the `mark_task_done` tool. ```json { "content": [{ "type": "text", "text": "Error: Task ID required" }], "isError": true } ``` -------------------------------- ### Example Token Exchange Flow Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Illustrates the complete flow from generating an auth URL to exchanging the authorization code for tokens. Assumes the user has completed the consent flow and the redirect URL is available. ```javascript const authUrl = '...'; console.log('Visit:', authUrl); // User grants access and is redirected to: // http://localhost:3000/oauth2/callback?code=4/0AVG5wmRu...&scope=... const code = '4/0AVG5wmRu...'; const { tokens } = await oAuth2Client.getToken(code); // tokens now contains access_token, refresh_token, expiry_date ``` -------------------------------- ### Mark Task Done Error Response Example (Backend Failure) Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md An example of an error response when the backend API call fails for the `mark_task_done` tool. ```json { "content": [{ "type": "text", "text": "Error: Task not found" }], "isError": true } ``` -------------------------------- ### Gmail Worker Payload Example Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/types.md An example of the JSON output from the Gmail worker, illustrating the structure of the report, counts, tasks, and timestamp. ```json { "ok": true, "report": "# Talked to Gmail\n\n## 🚨 911 - HotSchedules Alerts\n...", "counts": { "hs": 3, "brinker": 2, "hs911": 1, "deliverables": 2 }, "tasks": [ { "id": "xyz123", "messageId": "18a4c5d7", "type": "911", "priority": "high", "subject": "URGENT: Call-off submitted", "...": "..." } ], "timestamp": "2026-05-31T18:30:00.000Z" } ``` -------------------------------- ### Classify Message Example Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/gmail-worker.md Demonstrates how to use the `classifyMessage` function with a sample message object. The output will be a structured object with classification details. ```javascript const task = classifyMessage({ id: '18a4c5d7e9f0b1c2', subject: 'URGENT: Call-off submitted', body: 'Coverage needed tomorrow...', from: 'alerts@hotschedules.com', threadId: 'abc123', date: 'Mon, 31 May 2026 10:30:00 +0000', snippet: 'Coverage needed...', link: 'https://mail.google.com/' }); // Returns { id: 'xyz789', type: '911', priority: 'high', ... } ``` -------------------------------- ### Example .env File Template Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md This is a template for the .env file, used to store runtime environment variables. Required variables include AI_SECRET_TOKEN, and optional variables like Google API credentials can also be set here. ```dotenv # Required: AI_SECRET_TOKEN=your_secret_token # Optional: PORT=3334 TIMEZONE='America/Detroit' GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_REDIRECT='http://localhost:3000/oauth2/callback' STORE_NAME=my_store ``` -------------------------------- ### Run Gmail Worker Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Commands to execute the Gmail worker. This typically involves installing dependencies and then running the worker script directly. ```bash npm run worker node gmail-worker.js ``` -------------------------------- ### Client-Side Handling of Tool Errors Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/errors.md This example demonstrates how a client can handle tool execution errors. It checks the `isError` flag in the result and logs the error message if an error occurred. ```javascript const result = await callTool('fetch_ops_report', {}); if (result.isError) { console.error('Tool failed:', result.content[0].text); } ``` -------------------------------- ### MCP Server Architecture Diagram Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Visual representation of the MCP server's architecture, showing the interaction between the Agent Builder/MCP Client, the MCP Server (server.js), and its dependencies like the Backend API, Gmail Worker, and OAuth Setup. ```text ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ Agent Builder / MCP Client │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │ (MCP WebSocket) │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ server.js │ │ (MCP Server) │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ │ │ ā”Œā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ Backend │ │ Gmail │ │ OAuth │ │ API │ │ Worker │ │ Setup │ │ (Vercel)│ │ (optional) │ │ (setup) │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │ │ ā”Œā”€ā”€ā”€ā–¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā–¼ā”€ā”€ā” │ Gmail API / Google Libs │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ``` -------------------------------- ### Execute and Log Gmail Worker Results Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/gmail-worker.md Example of how to call the runGmailWorker function and log its output. This demonstrates accessing the generated report and the classified message results. ```javascript const { report, results } = await runGmailWorker(); console.log(report); console.log(`Found ${results.hs911.length} urgent items`); ``` -------------------------------- ### Parse URL for OAuth Code Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/errors.md Attempts to parse a URL string to extract the authorization 'code' query parameter. This is a crucial step in the OAuth setup process. ```javascript try { const urlObj = new URL(url); const code = urlObj.searchParams.get('code'); ``` -------------------------------- ### Handle Unknown Tool Name Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/errors.md This error is thrown when the client calls tools/call with a tool name that is not recognized. The affected request shows an example of an invalid tool name. Clients can catch this by checking the 'isError' flag. ```javascript throw new Error(`Unknown tool: ${name}`); ``` ```json { "params": { "name": "invalid_tool_name", "arguments": {} } } ``` ```javascript const response = { content: [{ type: "text", text: "Error: Unknown tool: invalid_tool_name" }], isError: true }; ``` -------------------------------- ### Server.js Startup Flow Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md The sequence of operations for initializing the server, including loading environment variables, setting up the WebSocket server, and registering request handlers. ```javascript 1. dotenv.config() - Load .env 2. WebSocketServer({ port: PORT }) 3. On each connection: a. Log "āœ… Client connected" b. Create MCP Server instance c. Register request handlers d. Set up transport 4. Listen for client messages ``` -------------------------------- ### MCP Server Startup Configuration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md This JavaScript snippet shows the initialization of the Server class with basic metadata. It is used for setting up the server instance. ```javascript const server = new Server( { name: "ops-gmail-runner", version: "1.0.0" }, { capabilities: { tools: {} } } ); ``` -------------------------------- ### Initialize Git Repository Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/README.md Initializes a new Git repository, stages all files, and creates the initial commit. ```bash git init git add . git commit -m "Initial MCP server" ``` -------------------------------- ### Initialize WebSocket Server Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Sets up the WebSocket server to listen on a specified port. The port is determined by `process.env.PORT` or defaults to 3334. ```javascript const wss = new WebSocketServer({ port: PORT }); ``` -------------------------------- ### Create readline Interface for User Prompts Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Sets up a readline interface to interact with the user via the command line, prompting for necessary information like the redirect URL. ```javascript const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.question('3. Paste the entire redirect URL here: ', async (url) => { // Process URL and exchange code for tokens rl.close(); }); ``` -------------------------------- ### Server Initialization Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Initializes the WebSocket server, listening on a specified port. Each client connection spawns a new MCP Server instance. ```APIDOC ## Server Constructor ### Description Initializes the WebSocket server, listening on a specified port. Each client connection spawns a new MCP Server instance with capabilities and request handlers for tools. ### Parameters #### Query Parameters - **port** (number) - Optional - WebSocket server port, defaults to 3334, taken from `process.env.PORT`. ### Endpoint `ws://localhost:{PORT}` ### Source `server.js:14-17` ``` -------------------------------- ### Create Data Directories Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/errors.md Ensures that the './data' and './data/reports' directories exist before proceeding. If they do not exist, they are created. ```javascript if (!fs.existsSync('./data')) { fs.mkdirSync('./data', { recursive: true }); } ``` -------------------------------- ### Ops-MCP-Server File Structure Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Overview of the project's directory and file layout, detailing the purpose of key files and directories. ```text ops-mcp-server/ ā”œā”€ā”€ server.js # MCP server entry point ā”œā”€ā”€ gmail-worker.js # Gmail worker ā”œā”€ā”€ setup-gmail-oauth.js # OAuth setup ā”œā”€ā”€ package.json # Dependencies and scripts ā”œā”€ā”€ .env.example # Environment template ā”œā”€ā”€ railway.json # Deployment config └── data/ # Data directory (created at runtime) ā”œā”€ā”€ gmail_token.json # OAuth tokens ā”œā”€ā”€ latest_report.json # Latest worker output └── reports/ └── 2026-05-31-*.json # Timestamped reports ``` -------------------------------- ### Initialize OAuth2 Client Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Creates a Google OAuth2 client instance. Ensure GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REDIRECT environment variables are set. ```javascript const oAuth2Client = new google.auth.OAuth2( process.env.GOOGLE_CLIENT_ID, process.env.GOOGLE_CLIENT_SECRET, process.env.GOOGLE_REDIRECT || 'http://localhost:3000/oauth2/callback' ); ``` -------------------------------- ### Create and Write OAuth Token File Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/errors.md Ensures the './data' directory exists and then writes the obtained OAuth tokens to './data/gmail_token.json'. ```javascript if (!fs.existsSync('./data')) { fs.mkdirSync('./data'); } fs.writeFileSync('./data/gmail_token.json', JSON.stringify(tokens, null, 2)); ``` -------------------------------- ### Implement fetch_ops_report Tool Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Handles the 'fetch_ops_report' tool call by making a POST request to the Vercel backend API. It formats the response into a markdown report. ```javascript if (name === "fetch_ops_report") { const response = await fetch(`${VERCEL_BASE}/api/ops/fetch`, { method: "POST", headers: { "Authorization": `Bearer ${TOKEN}`, "Content-Type": "application/json" } }); if (!response.ok) { throw new Error(`API returned ${response.status}`); } const data = await response.json(); // ... format report ... } ``` ```javascript // Tool is called automatically by MCP client // Returns formatted markdown report const result = { content: [{ type: "text", text: "# Talked to Gmail\n\n## āœ… No 911 Issues\n..." }] }; ``` -------------------------------- ### Gmail API MessageListResponse Type Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/types.md Represents the response structure for listing Gmail messages. Use this to get message IDs and thread IDs. Full message content requires a separate getMessage() call. ```typescript { data: { messages?: Array<{ id: string; threadId: string; }>; } } ``` -------------------------------- ### Optional Environment Variables Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md Optional environment variables that can be configured to customize server behavior, such as port, Google API credentials, and timezone. ```bash PORT=3334 GOOGLE_CLIENT_ID=... GOOGLE_CLIENT_SECRET=... TIMEZONE=America/Detroit STORE_NAME=MyStore GOOGLE_REDIRECT=http://localhost:3000/oauth2/callback ``` -------------------------------- ### List Available Tools Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Registers and exposes the available tools that clients can discover and invoke. ```APIDOC ## Endpoint: tools/list ### Description Registers the available tools that clients can discover and call. ### Method POST ### Endpoint `/tools/list` ### Response #### Success Response (200) - **tools** (Array) - An array of available tools. - **name** (string) - The unique name of the tool. - **description** (string) - A description of what the tool does. - **inputSchema** (object) - The JSON schema defining the expected input for the tool. ### Response Example ```json { "tools": [ { "name": "fetch_ops_report", "description": "Fetch HotSchedules 12h call-offs and Brinker/Chili's 24h deadlines report", "inputSchema": { "type": "object", "properties": {} } }, { "name": "mark_task_done", "description": "Mark a task as complete by ID", "inputSchema": { "type": "object", "properties": { "id": { "type": "string", "description": "Task ID" } }, "required": ["id"] } } ] } ``` ### Source `server.js:36-58` ``` -------------------------------- ### Handle Gmail Search Errors Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/errors.md This snippet catches errors during Gmail API search operations. It logs the error message and returns an empty array, allowing processing to continue. The logged output shows an example of an 'invalid_grant' error. ```javascript } catch (error) { console.error('Gmail search error:', error.message); return []; } ``` ```text Gmail search error: invalid_grant ``` -------------------------------- ### Full Environment Variables for Gmail Integration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Lists all required and optional environment variables when using the MCP server with the Gmail worker. Includes Google API credentials. ```text ā˜‘ AI_SECRET_TOKEN (required) ā˜‘ GOOGLE_CLIENT_ID (required) ā˜‘ GOOGLE_CLIENT_SECRET (required) ☐ PORT (optional) ☐ TIMEZONE (optional) ☐ STORE_NAME (optional) ☐ GOOGLE_REDIRECT (optional) ``` -------------------------------- ### Configuration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Configuration details for the MCP Server, including environment variables and backend API endpoints. ```APIDOC ## Configuration ### Environment Variables - **PORT** (number) - Default: 3334 - WebSocket server port - **AI_SECRET_TOKEN** (string) - Description: Bearer token for backend API authentication ### Backend URLs #### Fetch Ops Report - **Endpoint**: `https://my-ops-runner.vercel.app/api/ops/fetch` - **Method**: POST #### Mark Task Complete - **Endpoint**: `https://my-ops-runner.vercel.app/api/ops/mark` - **Method**: POST ``` -------------------------------- ### OAuth2Client Initialization Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Initializes a Google OAuth2 client using environment variables for client ID, client secret, and redirect URL. This client is essential for managing authentication tokens. ```APIDOC ## OAuth2Client Initialization Creates a Google OAuth2 client with the provided credentials. ```javascript const oAuth2Client = new google.auth.OAuth2( process.env.GOOGLE_CLIENT_ID, process.env.GOOGLE_CLIENT_SECRET, process.env.GOOGLE_REDIRECT || 'http://localhost:3000/oauth2/callback' ); ``` ### Parameters - **clientId** (string) - Required - `GOOGLE_CLIENT_ID` env var - **clientSecret** (string) - Required - `GOOGLE_CLIENT_SECRET` env var - **redirectUrl** (string) - Required - Defaults to 'http://localhost:3000/oauth2/callback', sourced from `GOOGLE_REDIRECT` env var ### Returns OAuth2 client instance for token management. ``` -------------------------------- ### Server.js External Dependencies Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md Imports required for the main server entry point, including SDK components, WebSocket libraries, and environment variable loading. ```javascript import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { WebSocketServerTransport } from "@modelcontextprotocol/sdk/server/websocket/server.js"; import WebSocket, { WebSocketServer } from "ws"; import dotenv from "dotenv"; import fetch from "node-fetch"; ``` -------------------------------- ### tools/list Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md Returns the list of available tools that clients can discover. This endpoint uses the MCP RPC protocol. ```APIDOC ## tools/list ### Description Returns the list of available tools that clients can discover. ### Protocol MCP RPC ### Request ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/list" } ``` ### Response Schema ```typescript { tools: Array<{ name: string; description: string; inputSchema: { type: "object"; properties: Record; required?: string[]; }; }>; } ``` ``` -------------------------------- ### Fetch Ops Report Tool Request Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This is the JSON request format for executing the 'fetch_ops_report' tool, which requires no specific arguments. ```json { "method": "tools/call", "params": { "name": "fetch_ops_report", "arguments": {} } } ``` -------------------------------- ### Call a Tool Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Routes incoming tool calls to their respective handlers, supporting specified tools and their arguments. ```APIDOC ## Endpoint: tools/call ### Description Routes incoming tool calls to their respective handlers. Supports `fetch_ops_report` and `mark_task_done`. ### Method POST ### Endpoint `/tools/call` ### Parameters #### Request Body - **params** (object) - Required - Parameters for the tool call. - **name** (string) - Required - The name of the tool to call. - **arguments** (object) - Optional - The arguments to pass to the tool. ### Request Example ```json { "params": { "name": "mark_task_done", "arguments": { "id": "task-123" } } } ``` ### Response #### Success Response (200) - **content** (Array) - An array of content objects, typically text. - **type** (string) - The type of content, e.g., "text". - **text** (string) - The textual content of the response. - **isError** (boolean) - Optional - Indicates if an error occurred during tool execution. #### Response Example ```json { "content": [ { "type": "text", "text": "āœ… Task task-123 marked complete" } ] } ``` ### Throws - Error if tool name is unknown. - Error if required arguments are missing. - Error if API calls fail. ### Source `server.js:61-141` ``` -------------------------------- ### tools/call Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md Execute a named tool with arguments. This endpoint routes to the appropriate handler based on the tool name and uses the MCP RPC protocol. ```APIDOC ## tools/call ### Description Execute a named tool with arguments. Routes to handler based on tool name. ### Protocol MCP RPC ### Request Schema ```typescript { method: "tools/call"; params: { name: string; // "fetch_ops_report" or "mark_task_done" arguments: Record; } } ``` ### Response Schema ```typescript { content: Array<{ type: "text"; text: string; }>; isError?: boolean; } ``` ### Error Schema ```typescript { content: [{ type: "text"; text: string; // Error message }]; isError: true; } ``` ### Status Codes - 200 Success (tool executed, check `isError` flag) - Error on tool not found (returns error response) - Error on missing required arguments (returns error response) ``` -------------------------------- ### Add Remote Origin and Push Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/README.md Adds the GitHub repository as a remote origin and pushes the initial commit to the main branch. ```bash git remote add origin https://github.com/johnohhh1/ops-mcp-server.git git push -u origin main ``` -------------------------------- ### MCP Server Environment Variables Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Lists the required and optional environment variables for the MCP server. AI_SECRET_TOKEN is mandatory. ```text ā˜‘ AI_SECRET_TOKEN (required) ☐ PORT (optional, defaults to 3334) ``` -------------------------------- ### Register Tools List Handler Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Registers a handler for the 'tools/list' endpoint to allow clients to discover available tools. Each tool includes its name, description, and input schema. ```javascript server.setRequestHandler("tools/list", async () => ({ tools: [ { name: "fetch_ops_report", description: "Fetch HotSchedules 12h call-offs and Brinker/Chili's 24h deadlines report", inputSchema: { type: "object", properties: {} } }, { name: "mark_task_done", description: "Mark a task as complete by ID", inputSchema: { type: "object", properties: { id: { type: "string", description: "Task ID" } }, required: ["id"] } } ] })) ``` -------------------------------- ### Initialize WebSocketServerTransport Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Sets up the MCP transport layer for bidirectional communication over WebSocket. Connects the server to the transport and logs client disconnections. ```javascript const transport = new WebSocketServerTransport(socket, server); server.connect(transport); socket.on("close", () => { console.log("āŒ Client disconnected"); }); ``` -------------------------------- ### railway.json Deployment Configuration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md This file configures deployment settings for Railway.app. It specifies build methods (NIXPACKS) and deployment parameters like replicas and restart policies. ```json { "deploy": { "replicas": 1, "restartPolicy": "on-failure", "maxRestarts": 10 } } ``` -------------------------------- ### Store Tokens to File Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/oauth-setup.md Saves the obtained access and refresh tokens to a JSON file for persistent storage. The './data' directory is created if it doesn't exist. ```javascript const TOKEN_PATH = './data/gmail_token.json'; fs.writeFileSync('./data/gmail_token.json', JSON.stringify(tokens, null, 2)); ``` -------------------------------- ### Railway Deployment Configuration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Defines build and deployment settings for Railway. Specifies the builder and restart policies for the application. ```json { "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS" }, "deploy": { "numReplicas": 1, "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 10 } } ``` -------------------------------- ### Fetch Ops Report Response Format (Markdown) Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This markdown format illustrates the structure of the report returned by the fetch_ops_report tool, including alerts and deadlines. ```markdown # Talked to Gmail ## 🚨 911 - HotSchedules Alert [Message about call-offs or coverage issues] ## šŸ“… Deadlines & Deliverables [List of deadline items] ## Full Report [Detailed report from backend] ``` -------------------------------- ### Tools Discovery Request Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This is the JSON request format for the tools/list endpoint, used to discover available tools. ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/list" } ``` -------------------------------- ### Implement mark_task_done Tool Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Handles the 'mark_task_done' tool call by sending the task ID to the backend API. It requires the 'id' argument and returns a confirmation message. ```javascript if (name === "mark_task_done") { if (!args?.id) { throw new Error("Task ID required"); } const response = await fetch(`${VERCEL_BASE}/api/ops/mark`, { method: "POST", headers: { "Authorization": `Bearer ${TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ id: args.id }) }); const data = await response.json(); return { content: [{ type: "text", text: `āœ… Task ${args.id} marked complete` }] }; } ``` ```javascript // Tool call with id parameter const result = { content: [{ type: "text", text: "āœ… Task abc123 marked complete" }] }; ``` -------------------------------- ### Verification Checks Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Provides commands and file checks to verify successful deployment and operation of the MCP server and Gmail worker. ```text - MCP Server logs: šŸš€ MCP Server running on ws://localhost:{PORT} - Gmail Worker logs: šŸ”„ Starting Gmail worker... and āœ… Saved for MCP pickup - Check token file: ls -la ./data/gmail_token.json - Check latest report: cat ./data/latest_report.json ``` -------------------------------- ### Mark Task Done Tool Request Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This is the JSON structure for calling the `mark_task_done` tool, specifying the task ID to be marked as complete. ```json { "method": "tools/call", "params": { "name": "mark_task_done", "arguments": { "id": "abc123" } } } ``` -------------------------------- ### fetch_ops_report Tool Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Fetches operations reports including HotSchedules alerts and deadlines from the Vercel backend API. ```APIDOC ## Tool: fetch_ops_report ### Description Fetches operations reports from the Vercel backend API containing HotSchedules 911 alerts and Brinker/Chili's deadlines. ### Method POST ### Endpoint `/api/ops/fetch` (Internal API called by the tool) ### Parameters None (no input arguments required for the tool itself). ### Response #### Success Response - **content** (Array) - An array of content objects. - **type** (string) - The type of content, expected to be "text". - **text** (string) - Formatted markdown report. ### Response Example ```json { "content": [ { "type": "text", "text": "# Talked to Gmail\n\n## āœ… No 911 Issues\n..." } ] } ``` ### Throws - Error if backend API returns non-OK status. - Error if response parsing fails. ### Source `server.js:65-105` ``` -------------------------------- ### Node Version Requirement Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md Specifies the minimum required Node.js version for the project. Ensure your Node.js environment meets this requirement. ```json { "engines": { "node": ">=18.0.0" } } ``` -------------------------------- ### Backend API URLs Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md URLs for the backend APIs used by the MCP server to fetch reports and mark tasks as done. These are essential for external service integration. ```bash https://my-ops-runner.vercel.app/api/ops/fetch https://my-ops-runner.vercel.app/api/ops/mark ``` -------------------------------- ### Build Markdown Report from Results Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/gmail-worker.md Generates a formatted markdown report summarizing classified Gmail messages. It includes sections for urgent 911 alerts and deadlines/deliverables, along with a final summary count. Requires 'dayjs' library for date formatting. ```javascript function buildReport(results) { const lines = []; lines.push('# Talked to Gmail\n'); lines.push(`Generated: ${dayjs().tz(TZ).format('MMM D, YYYY h:mm A z')}\n`); if (results.hs911.length > 0) { lines.push('## 🚨 911 - HotSchedules Alerts'); results.hs911.forEach(item => { lines.push(`- **${item.subject}**`); lines.push(` From: ${item.from}`); lines.push(` [Open in Gmail](${item.link})`); }); } else { lines.push('## āœ… No 911 Issues'); lines.push('No call-offs or coverage issues in the last 12 hours'); } lines.push(''); if (results.deliverables.length > 0) { lines.push('## šŸ“… Deadlines & Deliverables'); results.deliverables.forEach(item => { const due = item.dueDate ? `Due: ${dayjs(item.dueDate).format('MMM D')}` : ''; lines.push(`- **${item.subject}** ${due}`); lines.push(` From: ${item.from}`); lines.push(` [Open in Gmail](${item.link})`); }); } else { lines.push('## No New Deadlines'); } lines.push(''); lines.push(`**Summary:** ${results.hs911.length} urgent, ${results.deliverables.length} deadlines, ${results.all.length} total`); return lines.join('\n'); } ``` -------------------------------- ### Gmail Worker.js Execution Flow Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md The orchestration steps for the Gmail worker, from setting up OAuth and loading tokens to searching, classifying messages, building reports, and saving output files. ```javascript 1. dotenv.config() - Load env 2. Set up Gmail OAuth client 3. Load tokens from ./data/gmail_token.json 4. runGmailWorker(): a. For each query in QUERIES: - Search Gmail - Get full messages - Classify each - Categorize by type b. Build markdown report c. Create payload with counts d. Save latest_report.json e. Save timestamped report f. Return report + results 5. Catch errors, exit with code 0/1 ``` -------------------------------- ### Required Environment Variable Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/README.md The essential environment variable required for the server's operation. This token is used for authentication and authorization. ```bash AI_SECRET_TOKEN=your-token-here ``` -------------------------------- ### Deliverable Detection Patterns Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/configuration.md These are regular expression patterns used by the Gmail worker to identify 'deliverable' items, such as tasks or reports with deadlines. ```regex due ``` ```regex deadline ``` ```regex submit ``` ```regex by friday ``` ```regex eop ``` ```regex end of period ``` ```regex schedule ready ``` -------------------------------- ### Gmail Worker.js External Dependencies Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/project-structure.md Imports for the standalone Gmail worker script, including environment configuration, Google API client, unique ID generation, and date/time utilities. ```javascript import 'dotenv/config'; import fs from 'fs'; import { google } from 'googleapis'; import { nanoid } from 'nanoid'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc.js'; import timezone from 'dayjs/plugin/timezone.js'; import * as chrono from 'chrono-node'; ``` -------------------------------- ### mark_task_done Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md Marks a task as complete by sending its ID to the backend API. This tool requires a valid task ID to be provided. ```APIDOC ## POST /api/ops/mark ### Description Marks a task as complete by sending its ID to the backend API. ### Method POST ### Endpoint /api/ops/mark ### Parameters #### Request Body - **id** (string) - Yes - Task ID to mark as complete ### Request Example ```json { "id": "abc123" } ``` ### Response #### Success Response (200) - **content** (array) - Confirmation message #### Response Example ```json { "content": [ { "type": "text", "text": "āœ… Task abc123 marked complete" } ] } ``` ### Errors - **Missing ID**: `id` argument not provided. Response: `Error: Task ID required` - **Backend error**: API call fails. Response: `Error: {error message}` ``` -------------------------------- ### Run Gmail Worker Orchestration Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/gmail-worker.md This is the main function that orchestrates the entire Gmail worker flow. It searches emails, classifies them, builds a report, and saves the results to disk. It requires environment variables like TIMEZONE and optionally STORE_NAME. ```javascript async function runGmailWorker() { console.log('šŸ”„ Starting Gmail worker...'); console.log(` Timezone: ${TZ}`); console.log(` Store: ${process.env.STORE_NAME || 'Not configured'}`); const results = { hs911: [], deliverables: [], all: [] }; for (const [key, config] of Object.entries(QUERIES)) { console.log(` šŸ“§ Running query: ${key}`); const messages = await searchMessages(config.query); console.log(` Found ${messages.length} messages`); for (const msg of messages) { const fullMessage = await getMessage(msg.id); if (fullMessage) { const classified = classifyMessage(fullMessage); if (classified) { results.all.push(classified); if (classified.type === '911') { results.hs911.push(classified); } else if (classified.type === 'deliverable') { results.deliverables.push(classified); } } } } } console.log(` šŸ“Š Results:`); console.log(` 911 items: ${results.hs911.length}`); console.log(` Deliverables: ${results.deliverables.length}`); console.log(` Total messages: ${results.all.length}`); const report = buildReport(results); // Save results const payload = { ok: true, report: report, counts: { hs: results.all.filter(r => r.from?.includes('hotschedules')).length, brinker: results.all.filter(r => r.from?.includes('brinker')).length, hs911: results.hs911.length, deliverables: results.deliverables.length }, tasks: results.all, timestamp: new Date().toISOString() }; if (!fs.existsSync('./data')) { fs.mkdirSync('./data', { recursive: true }); } const dataPath = './data/latest_report.json'; fs.writeFileSync(dataPath, JSON.stringify(payload, null, 2)); console.log('āœ… Saved for MCP pickup'); if (!fs.existsSync('./data/reports')) { fs.mkdirSync('./data/reports', { recursive: true }); } const localPath = './data/reports/' + dayjs().format('YYYY-MM-DD-HHmmss') + '.json'; fs.writeFileSync(localPath, JSON.stringify(payload, null, 2)); console.log('āœ… Saved report:', localPath); return { report, results }; } ``` -------------------------------- ### Error Handling Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Details on how errors are handled and returned by the MCP Server. ```APIDOC ## Error Handling ### Description All errors during tool execution are caught and returned as MCP error responses with `isError: true` flag. ### Error Conditions - Unknown tool name - Missing required arguments - API connection failures - Non-OK HTTP response codes ### Response Example ```json { "content": [ { "type": "text", "text": "Error: [error message]" } ], "isError": true } ``` ``` -------------------------------- ### mark_task_done Tool Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Marks a specified task as complete by sending its ID to the backend API. ```APIDOC ## Tool: mark_task_done ### Description Marks a task as complete by sending its ID to the backend API. ### Method POST ### Endpoint `/api/ops/mark` (Internal API called by the tool) ### Parameters #### Request Body (for the tool's arguments) - **id** (string) - Required - The task ID to mark as complete. ### Request Example (Tool Arguments) ```json { "id": "abc123" } ``` ### Response #### Success Response - **content** (Array) - An array of content objects. - **type** (string) - The type of content, expected to be "text". - **text** (string) - A confirmation message indicating the task was marked complete. #### Response Example ```json { "content": [ { "type": "text", "text": "āœ… Task abc123 marked complete" } ] } ``` ### Throws - Error if `id` argument is missing. - Error if backend API call fails. ### Source `server.js:107-129` ``` -------------------------------- ### MCPTool Type Definition Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/types.md Defines the structure for an MCP tool, including its name, description, and input schema. ```typescript { name: string; description: string; inputSchema: { type: 'object'; properties: Record; required?: string[]; }; } ``` -------------------------------- ### Register Tool Call Handler Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Registers a handler for the 'tools/call' endpoint to route incoming tool calls to their respective implementations based on the provided name and arguments. ```javascript server.setRequestHandler("tools/call", async (request) => { const { name, arguments: args } = request.params; // ... routing logic ... }) ``` -------------------------------- ### Tools Discovery Response Schema Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/endpoints.md This TypeScript schema defines the structure of the response from the tools/list endpoint, detailing available tools and their input schemas. ```typescript { tools: Array<{ name: string; description: string; inputSchema: { type: "object"; properties: Record; required?: string[]; }; }> } ``` -------------------------------- ### WebSocketServerTransport Source: https://github.com/johnohhh1/ops-mcp-server/blob/main/_autodocs/api-reference/mcp-server.md Sets up the MCP transport layer for bidirectional communication over WebSocket. It takes an individual client socket connection and an MCP Server instance as parameters. ```APIDOC ## WebSocketServerTransport ### Description Sets up the MCP transport layer for bidirectional communication over WebSocket. ### Parameters #### Path Parameters - **socket** (WebSocket) - Required - Individual client socket connection - **server** (Server) - Required - MCP Server instance ### Events - `close` - Fired when client disconnects ```