Skip to main content
Glama
Ejb503

SystemPrompt MCP Server

prompt-handlers.ts1.68 kB
import { GetPromptRequest, GetPromptResult, ListPromptsRequest, ListPromptsResult, } from "@modelcontextprotocol/sdk/types.js"; import { SystemPromptService } from "../services/systemprompt-service.js"; import { mapPromptToGetPromptResult, mapPromptsToListPromptsResult, } from "../utils/mcp-mappers.js"; import { PROMPTS } from "../constants/sampling-prompts.js"; export async function handleListPrompts( request: ListPromptsRequest ): Promise<ListPromptsResult> { try { const service = SystemPromptService.getInstance(); const remotePrompts = await service.getAllPrompts(); const allPrompts = mapPromptsToListPromptsResult(remotePrompts); return allPrompts; } catch (error: any) { console.error("Failed to fetch prompts:", error); throw new Error("Failed to fetch prompts from systemprompt.io"); } } export async function handleGetPrompt( request: GetPromptRequest ): Promise<GetPromptResult> { try { const service = SystemPromptService.getInstance(); const remotePrompts = await service.getAllPrompts(); const mappedRemotePrompts = remotePrompts.map((i) => mapPromptToGetPromptResult(i) ); const allPrompts = [...mappedRemotePrompts, ...PROMPTS]; const prompt = allPrompts.find((p) => p.name === request.params.name); if (!prompt) { throw new Error(`Prompt not found: ${request.params.name}`); } return { _meta: { prompt }, ...prompt, }; } catch (error: any) { console.error("Failed to fetch prompt:", error); throw new Error( `Failed to fetch prompt from systemprompt.io: ${ error.message || "Unknown error" }` ); } }

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/Ejb503/systemprompt-mcp-core'

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