get_ramp_statements
Retrieve Ramp financial statements with date filtering and pagination options to access transaction data efficiently.
Instructions
Retrieve Ramp statements with optional date filtering and pagination.
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_ramp_statements"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_date | No | Start date in ISO format (YYYY-MM-DD) | |
| to_date | No | End date in ISO format (YYYY-MM-DD) | |
| start | No | Token for pagination | |
| page_size | No | Number of results per page |
Implementation Reference
- The core handler logic that builds the Ramp API URL with input parameters, authenticates using context.accessToken, fetches statements, handles HTTP errors, and returns the parsed JSON data.
handler: async (input, context) => { // Build URL with query parameters const url = new URL("https://api.ramp.com/developer/v1/statements"); // Add query parameters if provided Object.entries(input).forEach(([key, value]) => { if (value !== undefined) { url.searchParams.append(key, String(value)); } }); // Set up request options const options = { method: "GET", headers: { accept: "application/json", authorization: `Bearer ${context.accessToken}`, }, }; // Make the API request const response = await fetch(url.toString(), options); if (!response.ok) { const errorText = await response.text(); throw new Error( `HTTP error! status: ${response.status} - ${errorText}` ); } const data = await response.json(); return data; }, - Zod-based input schema defining optional parameters for date range filtering and pagination.
inputSchema: { from_date: z.string().optional().describe("Start date in ISO format (YYYY-MM-DD)"), to_date: z.string().optional().describe("End date in ISO format (YYYY-MM-DD)"), start: z.string().optional().describe("Token for pagination"), page_size: z.number().optional().describe("Number of results per page") }, - src/tools/statements/get_ramp_statements.ts:4-46 (registration)Tool definition and export using defineTool, specifying name, description, schema, and handler for the get_ramp_statements tool.
export const GET_RAMP_STATEMENTS_TOOL = defineTool<any, RampContext>((z) => ({ name: "get_ramp_statements", description: "Retrieve Ramp statements with optional date filtering and pagination.", inputSchema: { from_date: z.string().optional().describe("Start date in ISO format (YYYY-MM-DD)"), to_date: z.string().optional().describe("End date in ISO format (YYYY-MM-DD)"), start: z.string().optional().describe("Token for pagination"), page_size: z.number().optional().describe("Number of results per page") }, handler: async (input, context) => { // Build URL with query parameters const url = new URL("https://api.ramp.com/developer/v1/statements"); // Add query parameters if provided Object.entries(input).forEach(([key, value]) => { if (value !== undefined) { url.searchParams.append(key, String(value)); } }); // Set up request options const options = { method: "GET", headers: { accept: "application/json", authorization: `Bearer ${context.accessToken}`, }, }; // Make the API request const response = await fetch(url.toString(), options); if (!response.ok) { const errorText = await response.text(); throw new Error( `HTTP error! status: ${response.status} - ${errorText}` ); } const data = await response.json(); return data; }, })); - src/index.ts:55-60 (registration)Final registration of the tool with the MCP server after applying context with access token.
server.tool( statementsTool.name, statementsTool.description, statementsTool.inputSchema, statementsTool.handler ); - src/utils/defineTool.ts:22-65 (helper)Generic helper utility for defining MCP tools with type-safe Zod schemas, context injection, standardized error responses, and MCP CallToolResult formatting.
export const defineTool = <TInputSchema extends z.ZodRawShape, TContext extends ToolContext = ToolContext>( cb: (zod: typeof z) => ToolDefinition<TInputSchema, TContext> ) => { const tool = cb(z); const wrappedHandler = async ( input: InferToolHandlerInput<TInputSchema>, extra: RequestHandlerExtra, context: TContext ): Promise<CallToolResult> => { try { const result = await tool.handler(input, context); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }; return { ...tool, handler: (input: InferToolHandlerInput<TInputSchema>, extra: RequestHandlerExtra) => wrappedHandler(input, extra, {} as TContext), withContext: (context: TContext) => ({ ...tool, handler: (input: InferToolHandlerInput<TInputSchema>, extra: RequestHandlerExtra) => wrappedHandler(input, extra, context), }), }; };