get_mileage
Retrieve mileage records from Simplicate business data to track and manage travel expenses for projects and clients.
Instructions
Retrieve mileage records
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_mileage"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
Implementation Reference
- The getMileage method retrieves mileage data from the Simplicate API endpoint '/costs/mileage'. It handles optional pagination parameters and gracefully returns an empty array on error.
async getMileage(params?: { limit?: number; offset?: number }): Promise<SimplicateMileage[]> { try { const response = await this.client.get('/costs/mileage', params); return response.data || []; } catch (error) { // Mileage endpoint may require specific filters console.warn('getMileage: endpoint returned error, returning empty array'); return []; } - TypeScript interface defining the structure of SimplicateMileage objects returned by getMileage.
export interface SimplicateMileage { id: string; employee?: { id: string; name: string }; project?: { id: string; name: string }; distance: number; date: string; rate: number; } - src/http-mcp-server.ts:25-54 (handler)Dynamic tool handler in HTTP MCP server that converts snake_case tool names like 'get_mileage' to camelCase method 'getMileage' on SimplicateServiceExtended and executes it with parsed arguments.
async function dispatchTool(toolName: string, args: any) { const method = toMethodName(toolName); // heuristic param extraction const params: any[] = []; if (args && typeof args === 'object') { // common id patterns const idKeys = ['project_id','organization_id','person_id','task_id','service_id','invoice_id','id']; let foundId = false; for (const k of idKeys) { if (k in args) { params.push(args[k]); foundId = true; break; } } if (args.data) params.push(args.data); if (!foundId && params.length === 0) params.push(args); } else if (args !== undefined) { params.push(args); } // @ts-ignore - dynamic call if (typeof (service as any)[method] === 'function') { // call and return // Some methods expect a single primitive id; spread params return await (service as any)[method](...params); } throw new Error(`Unknown tool/method: ${toolName} -> ${method}`); }