Skip to main content
Glama

Lightning Tools MCP Server

by getAlby
fetch_l402.ts1.67 kB
import { l402 } from "@getalby/lightning-tools"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { WebLNProvider } from "@webbtc/webln-types"; import { z } from "zod"; export function registerFetchL402Tool(server: McpServer, webln: WebLNProvider) { server.tool( "fetch_l402", "Fetch a paid resource protected by L402", { url: z.string().describe("the URL to fetch"), method: z.string().nullish().describe("HTTP request method. Default GET"), body: z .string() .nullish() .describe( "HTTP request body as a string (either plaintext or stringified JSON)" ), }, async (params) => { const requestOptions: RequestInit = { method: params.method || undefined, }; if ( params.method && params.method !== "GET" && params.method !== "HEAD" ) { requestOptions.body = params.body; requestOptions.headers = { "Content-Type": "application/json", }; } const result = await l402.fetchWithL402(params.url, requestOptions, { webln, }); const responseContent = await result.text(); if (!result.ok) { console.error( "L402 fetch returned non-OK status", result.status, responseContent ); throw new Error( "fetch returned non-OK status: " + result.status + " " + responseContent ); } return { content: [ { type: "text", text: responseContent, }, ], }; } ); }

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/getAlby/lightning-tools-mcp-server'

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