Skip to main content
Glama

pay_and_get_402_protected_url

Access HTTP 402 protected content by processing payments through your P-Link account to retrieve the requested URL data.

Instructions

Pay a HTTP 402 protected URL using your P-Link managed account, and returns the result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe 402 protected URL (can be any link complying to the x402 protocol)

Implementation Reference

  • The main asynchronous handler function that implements the tool logic: extracts the URL from args, resolves the API key, sends a POST request to the backend to pay for the 402-protected resource, logs the response, parses it as JSON, and returns the result.
    export async function pay_and_get_402_protected_url(args: any) { const { url } = args; const { apiKey } = resolveAuth(undefined, undefined); var jsP = { myKey: apiKey, url } const fet = await fetch(BASE + '/api/pay402link', { method: 'POST', headers: { Accept: 'application.json', 'Content-Type': 'application/json' }, body: JSON.stringify(jsP) }); var dat = await fet.text(); process.stderr.write(`[caisse][info] dat2 ${dat}\n`); var result = JSON.parse(dat); return result; }
  • The Zod schema defining the input shape for the tool: requires a 'url' string with description.
    export const get402clientShape = { url: z.string().describe("The 402 protected URL (can be any link complying to the x402 protocol)") } ;
  • src/solution.ts:80-85 (registration)
    The tool registration object in the tools array, which defines the name, description (from imported title), inputSchema (derived from get402clientShape), and annotations. This is returned by the ListToolsRequest handler.
    { name: "pay_and_get_402_protected_url", description: auth402_title, inputSchema: jsonSchema(zodToJsonSchema(z.object(get402clientShape))).jsonSchema, annotations: { title: 'Pay 402 link', destructiveHint: true, openWorldHint: true } }
  • The switch case in the CallToolRequest handler that routes calls to this tool name by invoking the imported handler function with the arguments.
    case "pay_and_get_402_protected_url": result = await pay_and_get_402_protected_url(args); break;
  • A helper function to register the tool on an MCP server using the standard SDK method, though not used in this codebase's main server setup.
    export function register402client(server: McpServer ) { server.registerTool( 'pay_and_get_402_protected_url', { title: auth402_title, description: auth402_title, inputSchema: get402clientShape, annotations: { title: auth402_title, destructiveHint: true, openWorldHint: true } }, async (e) => await wrapResult(pay_and_get_402_protected_url, e) ); }

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/paracetamol951/P-Link-MCP'

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