UNPKG

@chargetrip/mcp

Version:

Chargetrip MCP server

34 lines (31 loc) 1.16 kB
import { Operator } from '@chargetrip/types'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; import z from 'zod'; import { operatorQuery } from '../../../constants'; import { FetchAndProcessUtil, MappingOperatorUtil } from '../../../utils'; export function registerOperatorById(server: McpServer): void { server.tool( 'operator_by_id', 'Retrieves full details of a charging station operator (charge point operator or CPO) by its ID from the Chargetrip API.', { id: z .string() .optional() .describe( 'The ID of the charging station operator (CPO) to retrieve. This is a required field. You can find the ID by using the `operator_list` tool.', ), }, async (input): Promise<CallToolResult> => { const variables = { id: input.id, }; return FetchAndProcessUtil.getItem<Operator>({ itemName: 'operator', query: operatorQuery, variables, mapFunction: operator => MappingOperatorUtil.mapOperator({ operator }).join('\n'), }); }, ); }