get_resource
Fetch specific Lithic resources like cards, accounts, or transactions by providing resource type and ID. Simplify access to banking and card services data.
Instructions
Get a specific Lithic resource by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resourceId | Yes | ID/token of the resource to fetch | |
| resourceType | Yes | Type of resource (card, account, transaction, etc.) |
Implementation Reference
- src/index.ts:155-190 (handler)The handler for the 'get_resource' tool within the CallToolRequestSchema request handler. It validates input parameters, maps the resource type to the appropriate API endpoint, fetches the resource from the Lithic API, and returns the JSON response or an error message.if (request.params.name === "get_resource") { try { // Parse and validate arguments const args = z.object({ resourceType: resourceTypeSchema, resourceId: resourceIdSchema }).parse(request.params.arguments); // Map to standardized resource type const standardizedResourceType = RESOURCE_MAP[args.resourceType.toLowerCase()] || args.resourceType; // Map resource type to endpoint const endpoint = mapResourceTypeToEndpoint(standardizedResourceType); const response = await lithicApi.get(`${endpoint}/${args.resourceId}`); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2) } ] }; } catch (error: any) { console.error(`Error fetching resource:`, error.message); return { isError: true, content: [ { type: "text", text: `Error fetching resource: ${error.message}` } ] }; }
- src/index.ts:79-116 (registration)Registers the 'get_resource' tool (along with 'list_resources') in the MCP server's list_tools handler, providing the tool's name, description, and input schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "get_resource", description: "Get a specific Lithic resource by ID", inputSchema: { type: "object", properties: { resourceType: { type: "string", description: "Type of resource (card, account, transaction, etc.)" }, resourceId: { type: "string", description: "ID/token of the resource to fetch" } }, required: ["resourceType", "resourceId"] } }, { name: "list_resources", description: "List resources of a specific type", inputSchema: { type: "object", properties: { resourceType: { type: "string", description: "Type of resource to list (cards, accounts, transactions, etc.)" } }, required: ["resourceType"] } } ] }; });
- src/index.ts:60-61 (schema)Zod schemas used for validating the resourceType and resourceId parameters in the get_resource tool handler.const resourceIdSchema = z.string().describe("Resource ID or token"); const resourceTypeSchema = z.string().describe("Type of resource to fetch");
- src/index.ts:29-47 (helper)Mapping object used to standardize various resource type names to their canonical API resource types for the get_resource tool.const RESOURCE_MAP: Record<string, string> = { 'card': 'card', 'account': 'account', 'financial_account': 'financial_account', 'financial-account': 'financial_account', 'credit': 'financial_account', 'credit-account': 'financial_account', 'transaction': 'transaction', 'event': 'event', 'balance': 'balance', 'dispute': 'dispute', 'bank': 'external_bank_account', 'bank-account': 'external_bank_account', 'external_bank_account': 'external_bank_account', 'report': 'report', 'webhook': 'webhook', 'card_program': 'card_program', 'account_holder': 'account_holder' };
- src/index.ts:119-148 (helper)Helper function that maps a standardized resource type to the corresponding Lithic API endpoint path, used in the get_resource handler.function mapResourceTypeToEndpoint(resourceType: string): string { switch (resourceType) { case 'card': return '/cards'; case 'account': return '/accounts'; case 'financial_account': return '/financial_accounts'; case 'transaction': return '/transactions'; case 'external_bank_account': return '/external_bank_accounts'; case 'event': return '/events'; case 'balance': return '/balances'; case 'card_program': return '/card_programs'; case 'dispute': return '/disputes'; case 'report': return '/reports'; case 'webhook': return '/webhooks'; case 'account_holder': return '/account_holders'; default: return `/${resourceType}s`; // Default to pluralizing the resource type } }