Skip to main content
Glama

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_dateNoStart date in ISO format (YYYY-MM-DD)
to_dateNoEnd date in ISO format (YYYY-MM-DD)
startNoToken for pagination
page_sizeNoNumber 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") },
  • 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 );
  • 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), }), }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dragonkhoi/ramp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server