add_endpoint
Configure new API endpoints to extend Grove's Pocket Network server capabilities for accessing blockchain data across multiple networks.
Instructions
Dynamically add a new endpoint configuration (for extensibility)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique identifier for the endpoint | |
| name | Yes | Human-readable name | |
| path | Yes | URL path (e.g., "/api/users/:id") | |
| method | Yes | HTTP method | |
| description | Yes | Description of what the endpoint does | |
| category | Yes | Category for organization |
Implementation Reference
- The handler logic for the 'add_endpoint' tool within the handleEndpointTool function. It calls endpointManager.addEndpoint with the provided arguments and returns a success or error response.case 'add_endpoint': { const endpoint = args as any; try { endpointManager.addEndpoint(endpoint); return { content: [ { type: 'text', text: `Successfully added endpoint: ${endpoint.id}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: error instanceof Error ? error.message : 'Failed to add endpoint', }, ], isError: true, }; } }
- src/handlers/endpoint-handlers.ts:76-110 (registration)Registration of the 'add_endpoint' tool in the tools array returned by registerEndpointHandlers, including name, description, and input schema.{ name: 'add_endpoint', description: 'Dynamically add a new endpoint configuration (for extensibility)', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the endpoint', }, name: { type: 'string', description: 'Human-readable name', }, path: { type: 'string', description: 'URL path (e.g., "/api/users/:id")', }, method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], description: 'HTTP method', }, description: { type: 'string', description: 'Description of what the endpoint does', }, category: { type: 'string', description: 'Category for organization', }, }, required: ['id', 'name', 'path', 'method', 'description', 'category'], }, },
- The core helper method addEndpoint in EndpointManager class that actually adds the new endpoint to the config, checks for duplicates, and updates categories.addEndpoint(endpoint: EndpointConfig): void { // Check if endpoint already exists if (this.config.endpoints.find(ep => ep.id === endpoint.id)) { throw new Error(`Endpoint with ID ${endpoint.id} already exists`); } // Add category if it doesn't exist if (!this.config.categories.includes(endpoint.category)) { this.config.categories.push(endpoint.category); } this.config.endpoints.push(endpoint); }