Skip to main content
Glama

store-routing-credentials

Idempotent

Store L402 macaroon and preimage after paying the Lightning invoice to enable automatic authentication for subsequent routing requests.

Instructions

Store L402 payment credentials (macaroon + preimage) after paying a routing invoice. Call this after the user has paid the Lightning invoice returned by a payment_required response. Once stored, all subsequent routing calls (score-venues, get-isochrone, get-directions) will authenticate automatically.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
macaroonYesThe macaroon from the payment_required response
preimageYesThe payment preimage obtained after paying the invoice

Implementation Reference

  • Handler function that stores L402 payment credentials (macaroon + preimage) on the RoutingClient instance after a user pays a Lightning invoice.
    export async function handleStoreRoutingCredentials(
      args: {
        macaroon: string
        preimage: string
      },
      routingClient: RoutingClient,
    ) {
      console.error('Storing L402 routing credentials')
    
      routingClient.storeL402Credentials(args.macaroon, args.preimage)
    
      return {
        content: [{
          type: 'text' as const,
          text: JSON.stringify({
            success: true,
            message: 'L402 credentials stored. Subsequent routing calls will authenticate automatically.',
          }),
        }],
      }
    }
  • Input schema using Zod validation: 'macaroon' (base64 string, 1-4096 chars) and 'preimage' (hex string, 1-128 chars), with idempotent annotation.
    inputSchema: {
      macaroon: z.string().min(1).max(4096).regex(/^[A-Za-z0-9+/=]+$/, 'Must be valid base64')
        .describe('The macaroon from the payment_required response'),
      preimage: z.string().min(1).max(128).regex(/^[0-9a-fA-F]+$/, 'Must be valid hex')
        .describe('The payment preimage obtained after paying the invoice'),
    },
    annotations: { readOnlyHint: false, idempotentHint: true },
  • Registers the 'store-routing-credentials' tool with the MCP server, wiring the Zod schema and handler.
    export function registerStoreCredentialsTool(server: McpServer, routingClient: RoutingClient): void {
      server.registerTool(
        'store-routing-credentials',
        {
          description:
            'Store L402 payment credentials (macaroon + preimage) after paying a routing invoice. ' +
            'Call this after the user has paid the Lightning invoice returned by a payment_required response. ' +
            'Once stored, all subsequent routing calls (score-venues, get-isochrone, get-directions) ' +
            'will authenticate automatically.',
          inputSchema: {
            macaroon: z.string().min(1).max(4096).regex(/^[A-Za-z0-9+/=]+$/, 'Must be valid base64')
              .describe('The macaroon from the payment_required response'),
            preimage: z.string().min(1).max(128).regex(/^[0-9a-fA-F]+$/, 'Must be valid hex')
              .describe('The payment preimage obtained after paying the invoice'),
          },
          annotations: { readOnlyHint: false, idempotentHint: true },
        },
        async (args) => handleStoreRoutingCredentials(args, routingClient),
      )
    }
  • src/index.ts:44-44 (registration)
    Main entry point where the store-credentials tool is registered via registerStoreCredentialsTool.
    registerStoreCredentialsTool(server, routingClient)
  • RoutingClient method that delegates to L402State.store() to persist the macaroon and preimage in memory.
    storeL402Credentials(macaroon: string, preimage: string): void {
      this.l402.store(macaroon, preimage)
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate idempotentHint=true and readOnlyHint=false, consistent with storage. Description adds workflow context (when to call and effect on future calls) beyond annotations. No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no wasted words, front-loaded with key action and context. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple store operation with two well-described parameters, the description provides complete workflow guidance and outcome. No output schema needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. Description adds only minimal context that parameters come from a payment_required response, not enhancing the schema definitions significantly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Store L402 payment credentials') and the resource ('macaroon + preimage'). It distinguishes from sibling tools by explaining that these credentials enable authentication for routing calls.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says to call after the user has paid a Lightning invoice from a payment_required response. Also notes that subsequent routing calls will authenticate automatically. No explicit when-not-to-use, but the context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/forgesworn/rendezvous-mcp'

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