update_endpoint
Modify existing API endpoint configurations including HTTP methods, URLs, headers, request parameters, and response schemas to maintain accurate API documentation and testing workflows.
Instructions
Update existing endpoint configuration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint_id | Yes | Endpoint ID to update (required) | |
| name | No | Updated endpoint name (optional) | |
| method | No | Updated HTTP method (optional) | |
| url | No | Updated endpoint URL (optional) | |
| description | No | Updated endpoint description (optional) | |
| headers | No | Updated request headers as key-value pairs | |
| body | No | Updated request body (JSON string) | |
| purpose | No | Updated business purpose (optional) | |
| request_params | No | Updated parameter documentation: {param_name: "description"} | |
| response_schema | No | Updated response field documentation: {field_name: "description"} | |
| header_docs | No | Updated header documentation: {header_name: "description"} |
Implementation Reference
- Primary handler function that executes the update_endpoint tool: validates input, formats data, calls backendClient.updateEndpoint, handles response and errors.export async function handleUpdateEndpoint(args: Record<string, any>): Promise<McpToolResponse> { try { console.error('[UPDATE-HANDLER] Starting update endpoint with args:', args); console.error('[UPDATE-HANDLER] About to get dependencies...'); const { configManager, backendClient } = await getEndpointDependencies(); console.error('[UPDATE-HANDLER] Dependencies loaded successfully'); const endpointId = args.endpoint_id as string; const name = args.name as string | undefined; const method = args.method as HttpMethod | undefined; const url = args.url as string | undefined; const description = args.description as string | undefined; const headers = args.headers as Record<string, string> | undefined; const body = args.body as string | undefined; // Build update data const updateData: any = {}; if (name !== undefined) updateData.name = name.trim(); if (method !== undefined) updateData.method = method; if (url !== undefined) updateData.url = url.trim(); if (description !== undefined) updateData.description = description.trim() || null; if (headers !== undefined) updateData.headers = formatHeaders(headers); if (body !== undefined) updateData.body = formatBody(body); // Validate const validationErrors = validateUpdateData({ endpoint_id: endpointId, updateData }); if (validationErrors.length > 0) { throw new Error(validationErrors.join('\n')); } // Update endpoint using BackendClient console.error(`[EndpointTools] Updating endpoint: ${endpointId}`); const result = await backendClient.updateEndpoint(endpointId, updateData); if (!result.success) { throw new Error(`Failed to update endpoint: ${result.error || 'Unknown error'}`); } if (result.data) { const updateText = formatEndpointUpdateText(result.data); return { content: [ { type: 'text', text: updateText } ] }; } else { return { content: [ { type: 'text', text: `❌ Failed to update endpoint: No data returned` } ], isError: true }; } } catch (error) { console.error('[UPDATE-HANDLER] Error caught:', error); return { content: [ { type: 'text', text: `❌ Endpoint update error: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/endpoints/tools.ts:118-188 (schema)McpTool definition for 'update_endpoint' including name, description, and detailed inputSchema for parameters.export const updateEndpointTool: McpTool = { name: 'update_endpoint', description: 'Update existing endpoint configuration', inputSchema: { type: 'object', properties: { endpoint_id: { type: 'string', description: 'Endpoint ID to update (required)' }, name: { type: 'string', description: 'Updated endpoint name (optional)' }, method: { type: 'string', description: 'Updated HTTP method (optional)', enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] }, url: { type: 'string', description: 'Updated endpoint URL (optional)' }, description: { type: 'string', description: 'Updated endpoint description (optional)' }, headers: { type: 'object', description: 'Updated request headers as key-value pairs', additionalProperties: { type: 'string', description: 'Header value' } }, body: { type: 'string', description: 'Updated request body (JSON string)' }, purpose: { type: 'string', description: 'Updated business purpose (optional)' }, request_params: { type: 'object', description: 'Updated parameter documentation: {param_name: "description"}', additionalProperties: { type: 'string', description: 'Parameter description' } }, response_schema: { type: 'object', description: 'Updated response field documentation: {field_name: "description"}', additionalProperties: { type: 'string', description: 'Response field description' } }, header_docs: { type: 'object', description: 'Updated header documentation: {header_name: "description"}', additionalProperties: { type: 'string', description: 'Header description' } } }, required: ['endpoint_id'] } };
- src/tools/endpoints/handlers.ts:36-44 (registration)Registers the handler for 'update_endpoint' by mapping updateEndpointTool.name to handleUpdateEndpoint in the tool handlers object.export function createEndpointToolHandlers(): Record<string, EndpointToolHandler> { return { [listEndpointsTool.name]: handleListEndpoints, [getEndpointDetailsTool.name]: handleGetEndpointDetails, [createEndpointTool.name]: handleCreateEndpoint, [updateEndpointTool.name]: handleUpdateEndpoint, [deleteEndpointTool.name]: handleDeleteEndpoint }; }
- src/tools/endpoints/tools.ts:208-214 (registration)Adds updateEndpointTool to the ENDPOINT_TOOLS array, which collects all endpoint management tools for MCP registration.export const ENDPOINT_TOOLS: McpTool[] = [ listEndpointsTool, getEndpointDetailsTool, createEndpointTool, updateEndpointTool, deleteEndpointTool ];