Skip to main content
Glama

MCP-NOSTR

by pablof7z
utils.ts1.21 kB
import type { NDKEvent, NDKSigner } from "@nostr-dev-kit/ndk"; import { NDKPrivateKeySigner } from "@nostr-dev-kit/ndk"; import { ndk } from "../../ndk.js"; import { getUser } from "../../config.js"; import { toPubkeys, toSnippet } from "../converters/index.js"; export const SNIPPET_KIND = 1337; /** * Gets the appropriate signer based on the username * @param username Username to get signer for (or "main" for default) * @returns The signer to use * @throws Error if user not found or missing nsec */ export async function getSigner(username?: string): Promise<NDKSigner> { // If no username or "main", return the default signer if (!username || username === "main") { if (!ndk.signer) { throw new Error("No default signer configured"); } return ndk.signer; } // Otherwise, get the user's signer const userData = getUser(username); if (!userData?.nsec) { throw new Error(`User "${username}" not found in config or missing nsec`); } return new NDKPrivateKeySigner(userData.nsec); } // Re-export converter functions for backward compatibility export { toPubkeys as identifierToPubkeys, toSnippet as eventToSnippet };

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/pablof7z/mcp-code'

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