@forprompt/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +302 -0
- package/dist/cli/index.js +3143 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +439 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +308 -0
- package/dist/index.d.ts +308 -0
- package/dist/index.js +406 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/chunk-2ABKAGKB.js +2145 -0
- package/dist/mcp/chunk-2ABKAGKB.js.map +1 -0
- package/dist/mcp/index.d.ts +36 -0
- package/dist/mcp/index.js +241 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +39 -0
- package/dist/mcp/server.js +10 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/version.cjs +118 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.cts +12 -0
- package/dist/version.d.ts +12 -0
- package/dist/version.js +91 -0
- package/dist/version.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/server.ts","../../src/types.ts","../../src/client.ts","../../src/mcp/tools.ts","../../src/mcp/resources.ts","../../package.json","../../src/version.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * ForPrompt MCP Server\n *\n * Model Context Protocol server that exposes ForPrompt prompts as\n * resources and tools for AI assistants like Claude, Cursor, and Continue.\n *\n * Usage:\n * npx forprompt mcp start\n * FORPROMPT_API_KEY=fp_xxx npx forprompt-mcp\n */\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { createForPrompt, ForPrompt } from \"../client.js\";\nimport { registerTools } from \"./tools.js\";\nimport { registerResources } from \"./resources.js\";\nimport { VERSION } from \"../version.js\";\n\nexport interface ForPromptMcpServerConfig {\n apiKey?: string;\n baseUrl?: string;\n}\n\nexport class ForPromptMcpServer {\n private mcpServer: McpServer;\n private forprompt: ForPrompt;\n private config: ForPromptMcpServerConfig;\n\n constructor(config: ForPromptMcpServerConfig = {}) {\n this.config = config;\n\n // Create ForPrompt client (auto-loads from env if not provided)\n this.forprompt = createForPrompt({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n });\n\n // Create MCP server\n this.mcpServer = new McpServer({\n name: \"forprompt\",\n version: VERSION,\n });\n\n // Register capabilities\n this.registerCapabilities();\n }\n\n private registerCapabilities(): void {\n // Register tools (CRUD operations for prompts)\n registerTools(this.mcpServer, this.forprompt, this.config);\n\n // Register resources (prompts as readable content)\n registerResources(this.mcpServer, this.forprompt, this.config);\n }\n\n /**\n * Start the MCP server with stdio transport\n */\n async start(): Promise<void> {\n const transport = new StdioServerTransport();\n await this.mcpServer.connect(transport);\n }\n\n /**\n * Get the underlying MCP server instance\n */\n getServer(): McpServer {\n return this.mcpServer;\n }\n}\n\n/**\n * Create and start an MCP server\n */\nexport async function startMcpServer(\n config: ForPromptMcpServerConfig = {}\n): Promise<ForPromptMcpServer> {\n const server = new ForPromptMcpServer(config);\n await server.start();\n return server;\n}\n\n// Run server if executed directly\n// Check if this file is being run directly as the main module\nfunction isMainModule(): boolean {\n const arg1 = process.argv[1] || \"\";\n return (\n arg1.endsWith(\"forprompt-mcp\") ||\n arg1.endsWith(\"server.js\") ||\n arg1.includes(\"mcp/server\")\n );\n}\n\nif (isMainModule()) {\n startMcpServer().catch((error) => {\n console.error(\"Failed to start MCP server:\", error);\n process.exit(1);\n });\n}\n","/**\n * ForPrompt SDK Types\n */\n\nexport interface ForPromptConfig {\n /** API key from ForPrompt dashboard (required) */\n apiKey: string;\n /** Custom base URL (optional, defaults to https://wooden-fox-811.convex.site) */\n baseUrl?: string;\n}\n\nexport interface Prompt {\n /** Unique key identifier for the prompt */\n key: string;\n /** Display name of the prompt */\n name: string;\n /** Optional description */\n description?: string;\n /** Version number */\n versionNumber: number;\n /** The system prompt content */\n systemPrompt: string;\n /** Last update timestamp */\n updatedAt: number;\n /** Prompt information fields */\n purpose?: string;\n expectedBehavior?: string;\n inputFormat?: string;\n outputFormat?: string;\n constraints?: string;\n useCases?: string;\n additionalNotes?: string;\n toolsNotes?: string;\n}\n\nexport interface Tool {\n /** Tool ID */\n id: string;\n /** Tool name */\n name: string;\n /** Tool description */\n description: string;\n /** JSON schema of parameters */\n parameters: string;\n /** Tool category */\n category?: string;\n /** Example usage */\n exampleUsage?: string;\n}\n\nexport interface PromptTool {\n /** Tool reference */\n tool: Tool;\n /** Whether the tool is required */\n isRequired: boolean;\n /** Usage notes for this prompt */\n usageNotes?: string;\n}\n\nexport interface GetPromptOptions {\n /** Specific version number to fetch (optional, defaults to active version) */\n version?: number;\n}\n\nexport class ForPromptError extends Error {\n constructor(\n message: string,\n public statusCode: number,\n public code: string\n ) {\n super(message);\n this.name = \"ForPromptError\";\n }\n}\n\n/**\n * Sync configuration\n */\nexport interface SyncConfig {\n // Connection\n baseUrl: string;\n projectId: string;\n apiKey: string;\n\n // Webhook settings\n webhookPort?: number; // Default: 3847\n webhookPath?: string; // Default: \"/forprompt-webhook\"\n\n // Polling fallback\n pollingInterval?: number; // Default: 60000 (1 minute)\n enablePolling?: boolean; // Default: true\n\n // Output settings\n outputDir: string; // e.g., \"./prompts\"\n format: \"typescript\" | \"json\" | \"yaml\" | \"all\";\n\n // Callbacks\n onSync?: (prompts: Prompt[]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * Webhook event payload\n */\nexport interface WebhookEvent {\n event: string;\n timestamp: number;\n projectId: string;\n data: {\n promptId?: string;\n promptKey?: string;\n versionNumber?: number;\n systemPrompt?: string;\n [key: string]: any;\n };\n}\n\n/**\n * Sync response from API\n */\nexport interface SyncResponse {\n projectId: string;\n syncedAt: number;\n prompts: Prompt[];\n}\n","/**\n * ForPrompt Client\n *\n * Simple usage with auto-configuration:\n * @example\n * ```typescript\n * import { forprompt } from \"@forprompt/sdk\";\n *\n * // Auto-loads from FORPROMPT_API_KEY env variable\n * const prompt = await forprompt.getPrompt(\"userContextPrompt\");\n * ```\n */\n\nimport type { ForPromptConfig, Prompt, GetPromptOptions } from \"./types\";\nimport { ForPromptError } from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://wooden-fox-811.convex.site\";\nconst DEFAULT_TIMEOUT = 30_000; // 30 seconds\nconst DEFAULT_RETRIES = 3;\n\n/**\n * Extended client configuration with security options\n */\nexport interface ForPromptClientConfig {\n /** Project API key (required) */\n apiKey: string;\n /** Base URL for API (default: https://wooden-fox-811.convex.site) */\n baseUrl?: string;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Number of retry attempts for failed requests (default: 3) */\n retries?: number;\n}\n\n/**\n * Calculate exponential backoff delay with jitter\n */\nfunction getBackoffDelay(attempt: number): number {\n const baseDelay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s, ...\n const jitter = Math.random() * 500; // 0-500ms random jitter\n return Math.min(baseDelay + jitter, 30_000); // Max 30s\n}\n\nexport class ForPrompt {\n private baseUrl: string;\n private apiKey: string;\n private timeout: number;\n private retries: number;\n\n constructor(config: ForPromptClientConfig | ForPromptConfig | { apiKey: string; baseUrl?: string }) {\n this.apiKey = config.apiKey || \"\";\n this.baseUrl = (config.baseUrl || DEFAULT_BASE_URL).replace(/\\/$/, \"\");\n this.timeout = (config as ForPromptClientConfig).timeout ?? DEFAULT_TIMEOUT;\n this.retries = (config as ForPromptClientConfig).retries ?? DEFAULT_RETRIES;\n }\n\n /**\n * Fetch with timeout support using AbortController\n */\n private async fetchWithTimeout(\n url: string,\n options: RequestInit\n ): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n });\n return response;\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new ForPromptError(\n `Request timeout after ${this.timeout}ms`,\n 408,\n \"TIMEOUT\"\n );\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Fetch with retry and exponential backoff\n */\n private async fetchWithRetry(\n url: string,\n options: RequestInit\n ): Promise<Response> {\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < this.retries; attempt++) {\n try {\n const response = await this.fetchWithTimeout(url, options);\n\n // Don't retry client errors (4xx) - they won't succeed on retry\n if (response.status >= 400 && response.status < 500) {\n return response;\n }\n\n // Success\n if (response.ok) {\n return response;\n }\n\n // Server error (5xx) - will retry\n lastError = new ForPromptError(\n `Server error: ${response.status}`,\n response.status,\n \"SERVER_ERROR\"\n );\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n // Don't retry timeout errors\n if (error instanceof ForPromptError && error.code === \"TIMEOUT\") {\n throw error;\n }\n }\n\n // Wait before retrying (unless this is the last attempt)\n if (attempt < this.retries - 1) {\n const delay = getBackoffDelay(attempt);\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw lastError || new ForPromptError(\n \"Request failed after retries\",\n 500,\n \"RETRY_EXHAUSTED\"\n );\n }\n\n /**\n * Get a prompt by its key\n *\n * @example\n * ```typescript\n * const prompt = await forprompt.getPrompt(\"userContextPrompt\");\n * console.log(prompt.systemPrompt);\n * ```\n *\n * @example With specific version\n * ```typescript\n * const prompt = await forprompt.getPrompt(\"userContextPrompt\", { version: 2 });\n * ```\n */\n async getPrompt(key: string, options?: GetPromptOptions): Promise<Prompt> {\n if (!this.apiKey) {\n throw new ForPromptError(\n \"API key is required. Set FORPROMPT_API_KEY environment variable or pass apiKey in config.\",\n 401,\n \"MISSING_API_KEY\"\n );\n }\n\n // Input validation\n if (!key || typeof key !== \"string\") {\n throw new ForPromptError(\n \"Prompt key must be a non-empty string\",\n 400,\n \"INVALID_INPUT\"\n );\n }\n\n if (key.length > 256) {\n throw new ForPromptError(\n \"Prompt key must be 256 characters or less\",\n 400,\n \"INVALID_INPUT\"\n );\n }\n\n if (options?.version !== undefined) {\n if (!Number.isInteger(options.version) || options.version < 1) {\n throw new ForPromptError(\n \"Version must be a positive integer\",\n 400,\n \"INVALID_INPUT\"\n );\n }\n }\n\n const url = new URL(`${this.baseUrl}/api/prompts`);\n url.searchParams.set(\"key\", key);\n\n if (options?.version !== undefined) {\n url.searchParams.set(\"version\", String(options.version));\n }\n\n const response = await this.fetchWithRetry(url.toString(), {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": this.apiKey,\n },\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({ error: \"Unknown error\" }))) as { error?: string };\n throw new ForPromptError(\n errorData.error || `Failed to fetch prompt: ${key}`,\n response.status,\n response.status === 404 ? \"PROMPT_NOT_FOUND\" : \"API_ERROR\"\n );\n }\n\n return response.json() as Promise<Prompt>;\n }\n\n /**\n * Get multiple prompts by their keys\n *\n * Requests are made in parallel with concurrency limit to avoid overwhelming the server.\n *\n * @example\n * ```typescript\n * const prompts = await forprompt.getPrompts([\"userContext\", \"chatDefault\"]);\n * ```\n */\n async getPrompts(\n keys: string[],\n options?: GetPromptOptions\n ): Promise<Map<string, Prompt>> {\n // Limit concurrent requests to avoid overwhelming the server\n const CONCURRENCY_LIMIT = 5;\n const promptMap = new Map<string, Prompt>();\n\n // Process in batches\n for (let i = 0; i < keys.length; i += CONCURRENCY_LIMIT) {\n const batch = keys.slice(i, i + CONCURRENCY_LIMIT);\n\n const results = await Promise.allSettled(\n batch.map((key) => this.getPrompt(key, options))\n );\n\n results.forEach((result, index) => {\n if (result.status === \"fulfilled\") {\n promptMap.set(batch[index]!, result.value);\n }\n });\n }\n\n return promptMap;\n }\n}\n\n/**\n * Create a ForPrompt client instance\n *\n * @example With explicit config\n * ```typescript\n * import { createForPrompt } from \"@forprompt/sdk\";\n *\n * const client = createForPrompt({\n * apiKey: \"fp_xxx\",\n * });\n *\n * const prompt = await client.getPrompt(\"userContextPrompt\");\n * ```\n *\n * @example With timeout and retry config\n * ```typescript\n * const client = createForPrompt({\n * apiKey: \"fp_xxx\",\n * timeout: 10000, // 10 seconds\n * retries: 5,\n * });\n * ```\n *\n * @example Auto-config from environment\n * ```typescript\n * import { forprompt } from \"@forprompt/sdk\";\n *\n * // Uses FORPROMPT_API_KEY from environment\n * const prompt = await forprompt.getPrompt(\"userContextPrompt\");\n * ```\n */\nexport function createForPrompt(config?: Partial<ForPromptClientConfig>): ForPrompt {\n const apiKey = config?.apiKey || process.env.FORPROMPT_API_KEY || \"\";\n const baseUrl = config?.baseUrl || process.env.FORPROMPT_BASE_URL;\n\n return new ForPrompt({\n apiKey,\n baseUrl,\n timeout: config?.timeout,\n retries: config?.retries,\n });\n}\n\n/**\n * Default ForPrompt client instance\n *\n * Auto-configured from environment variables:\n * - FORPROMPT_API_KEY: Your project API key\n * - FORPROMPT_BASE_URL: Custom base URL (optional)\n *\n * @example\n * ```typescript\n * import { forprompt } from \"@forprompt/sdk\";\n *\n * const prompt = await forprompt.getPrompt(\"userContextPrompt\");\n * console.log(prompt.systemPrompt);\n * ```\n */\nexport const forprompt = createForPrompt();\n","/**\n * MCP Tool Handlers\n *\n * Exposes ForPrompt operations as MCP tools that AI assistants can execute.\n */\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { ForPrompt } from \"../client.js\";\nimport type { ForPromptMcpServerConfig } from \"./server.js\";\nimport type { Prompt, SyncResponse } from \"../types.js\";\n\nconst DEFAULT_BASE_URL = \"https://wooden-fox-811.convex.site\";\n\n/**\n * Get API config from config object or environment\n */\nfunction getApiConfig(config: ForPromptMcpServerConfig): {\n apiKey: string;\n baseUrl: string;\n} {\n const apiKey = config.apiKey || process.env.FORPROMPT_API_KEY;\n const baseUrl = (\n config.baseUrl ||\n process.env.FORPROMPT_BASE_URL ||\n DEFAULT_BASE_URL\n ).replace(/\\/$/, \"\");\n\n if (!apiKey) {\n throw new Error(\n \"API key is required. Set FORPROMPT_API_KEY environment variable.\"\n );\n }\n\n return { apiKey, baseUrl };\n}\n\n/**\n * Fetch all prompts using the sync endpoint\n */\nasync function fetchAllPrompts(\n config: ForPromptMcpServerConfig\n): Promise<Prompt[]> {\n const { apiKey, baseUrl } = getApiConfig(config);\n\n const response = await fetch(`${baseUrl}/api/sync`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({\n error: \"Unknown error\",\n }))) as { error?: string };\n throw new Error(errorData.error || `Failed to fetch prompts`);\n }\n\n const data = (await response.json()) as SyncResponse;\n return data.prompts;\n}\n\n/**\n * Create a new prompt\n */\nasync function createPrompt(\n config: ForPromptMcpServerConfig,\n data: {\n key: string;\n name: string;\n description?: string;\n systemPrompt?: string;\n }\n): Promise<{ promptId: string; versionId?: string; versionNumber?: number }> {\n const { apiKey, baseUrl } = getApiConfig(config);\n\n const response = await fetch(`${baseUrl}/api/prompts`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n body: JSON.stringify(data),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({\n error: \"Unknown error\",\n }))) as { error?: string };\n throw new Error(errorData.error || \"Failed to create prompt\");\n }\n\n return response.json() as Promise<{\n promptId: string;\n versionId?: string;\n versionNumber?: number;\n }>;\n}\n\n/**\n * Update a prompt\n */\nasync function updatePrompt(\n config: ForPromptMcpServerConfig,\n data: {\n key: string;\n name?: string;\n description?: string;\n purpose?: string;\n expectedBehavior?: string;\n inputFormat?: string;\n outputFormat?: string;\n constraints?: string;\n useCases?: string;\n additionalNotes?: string;\n toolsNotes?: string;\n }\n): Promise<{ promptId: string }> {\n const { apiKey, baseUrl } = getApiConfig(config);\n\n const response = await fetch(`${baseUrl}/api/prompts`, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n body: JSON.stringify(data),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({\n error: \"Unknown error\",\n }))) as { error?: string };\n throw new Error(errorData.error || \"Failed to update prompt\");\n }\n\n return response.json() as Promise<{ promptId: string }>;\n}\n\n/**\n * Create a new version for a prompt\n */\nasync function createVersionApi(\n config: ForPromptMcpServerConfig,\n data: {\n key: string;\n systemPrompt: string;\n description?: string;\n setAsActive?: boolean;\n }\n): Promise<{ versionId: string; versionNumber: number }> {\n const { apiKey, baseUrl } = getApiConfig(config);\n\n const response = await fetch(`${baseUrl}/api/prompts/versions`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n body: JSON.stringify(data),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({\n error: \"Unknown error\",\n }))) as { error?: string };\n throw new Error(errorData.error || \"Failed to create version\");\n }\n\n return response.json() as Promise<{ versionId: string; versionNumber: number }>;\n}\n\n/**\n * Delete a prompt\n */\nasync function deletePromptApi(\n config: ForPromptMcpServerConfig,\n key: string\n): Promise<{ success: boolean }> {\n const { apiKey, baseUrl } = getApiConfig(config);\n\n const response = await fetch(`${baseUrl}/api/prompts?key=${encodeURIComponent(key)}`, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({\n error: \"Unknown error\",\n }))) as { error?: string };\n throw new Error(errorData.error || \"Failed to delete prompt\");\n }\n\n return response.json() as Promise<{ success: boolean }>;\n}\n\n/**\n * Format a prompt for display\n */\nfunction formatPrompt(prompt: Prompt): string {\n const sections: string[] = [];\n\n sections.push(`# ${prompt.name}`);\n sections.push(`**Key:** ${prompt.key}`);\n sections.push(`**Version:** ${prompt.versionNumber}`);\n\n if (prompt.description) {\n sections.push(`**Description:** ${prompt.description}`);\n }\n\n sections.push(\"\");\n sections.push(\"## System Prompt\");\n sections.push(\"```\");\n sections.push(prompt.systemPrompt);\n sections.push(\"```\");\n\n if (prompt.purpose) {\n sections.push(\"\");\n sections.push(\"## Purpose\");\n sections.push(prompt.purpose);\n }\n\n if (prompt.expectedBehavior) {\n sections.push(\"\");\n sections.push(\"## Expected Behavior\");\n sections.push(prompt.expectedBehavior);\n }\n\n if (prompt.inputFormat) {\n sections.push(\"\");\n sections.push(\"## Input Format\");\n sections.push(prompt.inputFormat);\n }\n\n if (prompt.outputFormat) {\n sections.push(\"\");\n sections.push(\"## Output Format\");\n sections.push(prompt.outputFormat);\n }\n\n if (prompt.constraints) {\n sections.push(\"\");\n sections.push(\"## Constraints\");\n sections.push(prompt.constraints);\n }\n\n if (prompt.useCases) {\n sections.push(\"\");\n sections.push(\"## Use Cases\");\n sections.push(prompt.useCases);\n }\n\n if (prompt.additionalNotes) {\n sections.push(\"\");\n sections.push(\"## Additional Notes\");\n sections.push(prompt.additionalNotes);\n }\n\n if (prompt.toolsNotes) {\n sections.push(\"\");\n sections.push(\"## Tools Notes\");\n sections.push(prompt.toolsNotes);\n }\n\n return sections.join(\"\\n\");\n}\n\n// Define input schemas\nconst GetPromptInputSchema = z.object({\n key: z.string().describe(\"The unique key identifier for the prompt\"),\n version: z\n .number()\n .optional()\n .describe(\n \"Specific version number to fetch (optional, defaults to active version)\"\n ),\n});\n\nconst ListPromptsInputSchema = z.object({\n search: z\n .string()\n .optional()\n .describe(\"Optional search term to filter prompts by name or key\"),\n});\n\nconst SearchPromptsInputSchema = z.object({\n query: z.string().describe(\"Search query to find matching prompts\"),\n});\n\nconst GetMetadataInputSchema = z.object({\n key: z.string().describe(\"The unique key identifier for the prompt\"),\n});\n\nconst GetSystemPromptInputSchema = z.object({\n key: z.string().describe(\"The unique key identifier for the prompt\"),\n version: z.number().optional().describe(\"Specific version number (optional)\"),\n});\n\n// Write operation schemas\nconst CreatePromptInputSchema = z.object({\n key: z\n .string()\n .describe(\n \"Unique key identifier for the prompt (lowercase, no spaces, use underscores)\"\n ),\n name: z.string().describe(\"Human-readable name for the prompt\"),\n description: z.string().optional().describe(\"Description of what the prompt does\"),\n systemPrompt: z\n .string()\n .optional()\n .describe(\"Initial system prompt content (optional, can be added later)\"),\n});\n\nconst UpdatePromptInputSchema = z.object({\n key: z.string().describe(\"The unique key identifier for the prompt to update\"),\n name: z.string().optional().describe(\"New name for the prompt\"),\n description: z.string().optional().describe(\"New description\"),\n purpose: z.string().optional().describe(\"The purpose/goal of this prompt\"),\n expectedBehavior: z\n .string()\n .optional()\n .describe(\"Expected behavior when using this prompt\"),\n inputFormat: z.string().optional().describe(\"Expected input format\"),\n outputFormat: z.string().optional().describe(\"Expected output format\"),\n constraints: z.string().optional().describe(\"Constraints and limitations\"),\n useCases: z.string().optional().describe(\"Primary use cases\"),\n additionalNotes: z.string().optional().describe(\"Additional notes\"),\n toolsNotes: z.string().optional().describe(\"Notes about tool usage\"),\n});\n\nconst CreateVersionInputSchema = z.object({\n key: z.string().describe(\"The prompt key to create a new version for\"),\n systemPrompt: z.string().describe(\"The new system prompt content\"),\n description: z\n .string()\n .optional()\n .describe(\"Description of changes in this version\"),\n setAsActive: z\n .boolean()\n .optional()\n .describe(\"Whether to set this as the active version (default: true)\"),\n});\n\nconst DeletePromptInputSchema = z.object({\n key: z.string().describe(\"The unique key identifier for the prompt to delete\"),\n});\n\n// Setup operation schemas\nconst SetupProjectInputSchema = z.object({\n projectPath: z\n .string()\n .describe(\"Absolute path to the project root directory\"),\n language: z\n .enum([\"typescript\", \"javascript\", \"python\"])\n .optional()\n .describe(\"Programming language (auto-detected if not specified)\"),\n packageManager: z\n .enum([\"npm\", \"yarn\", \"pnpm\", \"bun\", \"pip\", \"poetry\", \"uv\"])\n .optional()\n .describe(\"Package manager to use (auto-detected if not specified)\"),\n});\n\nconst GenerateConfigInputSchema = z.object({\n projectPath: z.string().describe(\"Absolute path to the project root directory\"),\n apiKey: z.string().optional().describe(\"API key (will prompt user if not provided)\"),\n baseUrl: z.string().optional().describe(\"Custom API base URL (optional)\"),\n});\n\nconst GenerateExampleInputSchema = z.object({\n language: z\n .enum([\"typescript\", \"javascript\", \"python\"])\n .describe(\"Programming language for the example\"),\n useCase: z\n .enum([\"basic\", \"streaming\", \"with-tools\", \"react-hook\", \"nextjs-api\"])\n .describe(\"Type of example to generate\"),\n promptKey: z\n .string()\n .optional()\n .describe(\"Optional prompt key to use in the example\"),\n});\n\nconst DetectProjectInputSchema = z.object({\n projectPath: z.string().describe(\"Absolute path to the project root directory\"),\n});\n\nconst GetIntegrationGuideInputSchema = z.object({\n framework: z\n .enum([\"nextjs\", \"react\", \"express\", \"fastapi\", \"django\", \"flask\", \"generic\"])\n .describe(\"Framework to get integration guide for\"),\n language: z\n .enum([\"typescript\", \"javascript\", \"python\"])\n .optional()\n .describe(\"Programming language\"),\n});\n\n/**\n * Register all MCP tools\n */\nexport function registerTools(\n server: McpServer,\n client: ForPrompt,\n config: ForPromptMcpServerConfig\n): void {\n // Tool: Get a single prompt by key\n server.registerTool(\n \"forprompt_get_prompt\",\n {\n description:\n \"Fetch a prompt by its key from ForPrompt. Returns the system prompt content and metadata including purpose, expected behavior, constraints, and more.\",\n inputSchema: GetPromptInputSchema,\n },\n async ({ key, version }) => {\n try {\n const prompt = await client.getPrompt(key, { version });\n return {\n content: [\n {\n type: \"text\" as const,\n text: formatPrompt(prompt),\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error fetching prompt \"${key}\": ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: List all prompts\n server.registerTool(\n \"forprompt_list_prompts\",\n {\n description:\n \"List all available prompts in your ForPrompt project. Returns a summary of each prompt including key, name, description, and version.\",\n inputSchema: ListPromptsInputSchema,\n },\n async ({ search }) => {\n try {\n let prompts = await fetchAllPrompts(config);\n\n // Filter by search term if provided\n if (search) {\n const searchLower = search.toLowerCase();\n prompts = prompts.filter(\n (p) =>\n p.key.toLowerCase().includes(searchLower) ||\n p.name.toLowerCase().includes(searchLower) ||\n p.description?.toLowerCase().includes(searchLower)\n );\n }\n\n if (prompts.length === 0) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: search\n ? `No prompts found matching \"${search}\"`\n : \"No prompts found in this project\",\n },\n ],\n };\n }\n\n const lines = prompts.map((p) => {\n const desc = p.description ? ` - ${p.description}` : \"\";\n return `- **${p.key}** (v${p.versionNumber}): ${p.name}${desc}`;\n });\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `# ForPrompt Prompts\\n\\nFound ${prompts.length} prompt(s):\\n\\n${lines.join(\"\\n\")}`,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error listing prompts: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Search prompts\n server.registerTool(\n \"forprompt_search_prompts\",\n {\n description:\n \"Search prompts by text query. Searches across prompt names, keys, descriptions, purposes, and use cases.\",\n inputSchema: SearchPromptsInputSchema,\n },\n async ({ query }) => {\n try {\n const allPrompts = await fetchAllPrompts(config);\n const queryLower = query.toLowerCase();\n\n const matches = allPrompts.filter((p) => {\n const searchFields = [\n p.key,\n p.name,\n p.description,\n p.purpose,\n p.useCases,\n p.expectedBehavior,\n p.systemPrompt,\n ];\n return searchFields.some(\n (field) => field && field.toLowerCase().includes(queryLower)\n );\n });\n\n if (matches.length === 0) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `No prompts found matching \"${query}\"`,\n },\n ],\n };\n }\n\n const results = matches.map((p) => {\n const sections = [`## ${p.name} (\\`${p.key}\\`)`];\n if (p.description) sections.push(`*${p.description}*`);\n sections.push(`Version: ${p.versionNumber}`);\n if (p.purpose) sections.push(`**Purpose:** ${p.purpose}`);\n return sections.join(\"\\n\");\n });\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `# Search Results for \"${query}\"\\n\\nFound ${matches.length} matching prompt(s):\\n\\n${results.join(\"\\n\\n---\\n\\n\")}`,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error searching prompts: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Get prompt metadata only\n server.registerTool(\n \"forprompt_get_prompt_metadata\",\n {\n description:\n \"Get metadata for a prompt without the full system prompt content. Useful for understanding what a prompt does before fetching it.\",\n inputSchema: GetMetadataInputSchema,\n },\n async ({ key }) => {\n try {\n const prompt = await client.getPrompt(key);\n const metadata = {\n key: prompt.key,\n name: prompt.name,\n description: prompt.description,\n versionNumber: prompt.versionNumber,\n updatedAt: new Date(prompt.updatedAt).toISOString(),\n purpose: prompt.purpose,\n expectedBehavior: prompt.expectedBehavior,\n inputFormat: prompt.inputFormat,\n outputFormat: prompt.outputFormat,\n constraints: prompt.constraints,\n useCases: prompt.useCases,\n additionalNotes: prompt.additionalNotes,\n toolsNotes: prompt.toolsNotes,\n systemPromptLength: prompt.systemPrompt.length,\n };\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `# Metadata for \"${prompt.name}\"\\n\\n\\`\\`\\`json\\n${JSON.stringify(metadata, null, 2)}\\n\\`\\`\\``,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error fetching metadata for \"${key}\": ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Get raw system prompt only\n server.registerTool(\n \"forprompt_get_system_prompt\",\n {\n description:\n \"Get only the raw system prompt text without metadata. Useful when you just need the prompt content to use directly.\",\n inputSchema: GetSystemPromptInputSchema,\n },\n async ({ key, version }) => {\n try {\n const prompt = await client.getPrompt(key, { version });\n return {\n content: [\n {\n type: \"text\" as const,\n text: prompt.systemPrompt,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error fetching system prompt for \"${key}\": ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // ==================== WRITE OPERATIONS ====================\n\n // Tool: Create a new prompt\n server.registerTool(\n \"forprompt_create_prompt\",\n {\n description:\n \"Create a new prompt in ForPrompt. You can optionally include an initial system prompt content. The key must be unique, lowercase, and use underscores instead of spaces.\",\n inputSchema: CreatePromptInputSchema,\n },\n async ({ key, name, description, systemPrompt }) => {\n try {\n const result = await createPrompt(config, {\n key,\n name,\n description,\n systemPrompt,\n });\n\n let message = `Successfully created prompt \"${name}\" with key \"${key}\"`;\n if (result.versionNumber) {\n message += ` (v${result.versionNumber})`;\n }\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: message,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error creating prompt: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Update a prompt\n server.registerTool(\n \"forprompt_update_prompt\",\n {\n description:\n \"Update an existing prompt's metadata (name, description, purpose, expected behavior, etc.). To update the system prompt content, use forprompt_create_version instead.\",\n inputSchema: UpdatePromptInputSchema,\n },\n async (args) => {\n try {\n await updatePrompt(config, args);\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Successfully updated prompt \"${args.key}\"`,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error updating prompt: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Create a new version\n server.registerTool(\n \"forprompt_create_version\",\n {\n description:\n \"Create a new version of an existing prompt with updated system prompt content. This is the proper way to update the actual prompt text while maintaining version history.\",\n inputSchema: CreateVersionInputSchema,\n },\n async ({ key, systemPrompt, description, setAsActive }) => {\n try {\n const result = await createVersionApi(config, {\n key,\n systemPrompt,\n description,\n setAsActive,\n });\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Successfully created version ${result.versionNumber} for prompt \"${key}\"`,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error creating version: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Delete a prompt\n server.registerTool(\n \"forprompt_delete_prompt\",\n {\n description:\n \"Delete a prompt and all its versions. This action is irreversible. Use with caution.\",\n inputSchema: DeletePromptInputSchema,\n },\n async ({ key }) => {\n try {\n await deletePromptApi(config, key);\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Successfully deleted prompt \"${key}\" and all its versions`,\n },\n ],\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error deleting prompt: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // ==================== SETUP & INTEGRATION TOOLS ====================\n\n // Tool: Detect project type\n server.registerTool(\n \"forprompt_detect_project\",\n {\n description:\n \"Detect the project type, language, and package manager in a directory. Use this first before running setup to understand the project structure.\",\n inputSchema: DetectProjectInputSchema,\n },\n async ({ projectPath }) => {\n try {\n const fs = await import(\"fs\");\n const path = await import(\"path\");\n\n const detection = {\n language: null as string | null,\n packageManager: null as string | null,\n framework: null as string | null,\n hasForPrompt: false,\n configFiles: [] as string[],\n };\n\n // Check for package.json (Node.js/TypeScript/JavaScript)\n const packageJsonPath = path.join(projectPath, \"package.json\");\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n\n // Detect language\n if (packageJson.devDependencies?.typescript || packageJson.dependencies?.typescript) {\n detection.language = \"typescript\";\n } else {\n detection.language = \"javascript\";\n }\n\n // Check if ForPrompt is already installed\n if (packageJson.dependencies?.[\"@forprompt/sdk\"] || packageJson.devDependencies?.[\"@forprompt/sdk\"]) {\n detection.hasForPrompt = true;\n }\n\n // Detect framework\n if (packageJson.dependencies?.next) {\n detection.framework = \"nextjs\";\n } else if (packageJson.dependencies?.react) {\n detection.framework = \"react\";\n } else if (packageJson.dependencies?.express) {\n detection.framework = \"express\";\n }\n\n // Detect package manager\n if (fs.existsSync(path.join(projectPath, \"pnpm-lock.yaml\"))) {\n detection.packageManager = \"pnpm\";\n } else if (fs.existsSync(path.join(projectPath, \"yarn.lock\"))) {\n detection.packageManager = \"yarn\";\n } else if (fs.existsSync(path.join(projectPath, \"bun.lockb\"))) {\n detection.packageManager = \"bun\";\n } else if (fs.existsSync(path.join(projectPath, \"package-lock.json\"))) {\n detection.packageManager = \"npm\";\n }\n\n detection.configFiles.push(\"package.json\");\n }\n\n // Check for Python projects\n const pyprojectPath = path.join(projectPath, \"pyproject.toml\");\n const requirementsPath = path.join(projectPath, \"requirements.txt\");\n\n if (fs.existsSync(pyprojectPath)) {\n detection.language = \"python\";\n const content = fs.readFileSync(pyprojectPath, \"utf-8\");\n if (content.includes(\"poetry\")) {\n detection.packageManager = \"poetry\";\n } else if (content.includes(\"uv\")) {\n detection.packageManager = \"uv\";\n } else {\n detection.packageManager = \"pip\";\n }\n detection.configFiles.push(\"pyproject.toml\");\n\n // Detect Python framework\n if (content.includes(\"fastapi\")) {\n detection.framework = \"fastapi\";\n } else if (content.includes(\"django\")) {\n detection.framework = \"django\";\n } else if (content.includes(\"flask\")) {\n detection.framework = \"flask\";\n }\n\n // Check if forprompt is installed\n if (content.includes(\"forprompt\")) {\n detection.hasForPrompt = true;\n }\n } else if (fs.existsSync(requirementsPath)) {\n detection.language = \"python\";\n detection.packageManager = \"pip\";\n detection.configFiles.push(\"requirements.txt\");\n\n const content = fs.readFileSync(requirementsPath, \"utf-8\");\n if (content.includes(\"forprompt\")) {\n detection.hasForPrompt = true;\n }\n }\n\n // Check for existing ForPrompt config\n const forpromptConfigPath = path.join(projectPath, \".forprompt\");\n if (fs.existsSync(forpromptConfigPath)) {\n detection.configFiles.push(\".forprompt\");\n }\n\n if (!detection.language) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Could not detect project type at \"${projectPath}\". Make sure the path contains a package.json (Node.js) or pyproject.toml/requirements.txt (Python).`,\n },\n ],\n isError: true,\n };\n }\n\n const lines = [\n `# Project Detection Results`,\n ``,\n `**Path:** ${projectPath}`,\n `**Language:** ${detection.language}`,\n `**Package Manager:** ${detection.packageManager || \"unknown\"}`,\n `**Framework:** ${detection.framework || \"none detected\"}`,\n `**ForPrompt Installed:** ${detection.hasForPrompt ? \"Yes\" : \"No\"}`,\n `**Config Files Found:** ${detection.configFiles.join(\", \")}`,\n ``,\n ];\n\n if (!detection.hasForPrompt) {\n lines.push(`## Next Steps`);\n lines.push(``);\n lines.push(`1. Run \\`forprompt_setup_project\\` to install the SDK`);\n lines.push(`2. Run \\`forprompt_generate_config\\` to create the config file`);\n lines.push(`3. Use \\`forprompt_generate_example\\` to see usage examples`);\n } else {\n lines.push(`ForPrompt is already installed! You can:`);\n lines.push(`- Use \\`forprompt_list_prompts\\` to see available prompts`);\n lines.push(`- Use \\`forprompt_create_prompt\\` to create new prompts`);\n }\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: lines.join(\"\\n\"),\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error detecting project: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Setup project (install SDK)\n server.registerTool(\n \"forprompt_setup_project\",\n {\n description:\n \"Install the ForPrompt SDK in a project. Auto-detects the language and package manager, or you can specify them. Returns the command to run - you should execute it using your terminal/bash tool.\",\n inputSchema: SetupProjectInputSchema,\n },\n async ({ projectPath, language, packageManager }) => {\n try {\n const fs = await import(\"fs\");\n const path = await import(\"path\");\n\n // Auto-detect if not provided\n let detectedLanguage = language;\n let detectedPM = packageManager;\n\n if (!detectedLanguage || !detectedPM) {\n const packageJsonPath = path.join(projectPath, \"package.json\");\n const pyprojectPath = path.join(projectPath, \"pyproject.toml\");\n const requirementsPath = path.join(projectPath, \"requirements.txt\");\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n\n if (!detectedLanguage) {\n detectedLanguage = packageJson.devDependencies?.typescript ? \"typescript\" : \"javascript\";\n }\n\n if (!detectedPM) {\n if (fs.existsSync(path.join(projectPath, \"pnpm-lock.yaml\"))) {\n detectedPM = \"pnpm\";\n } else if (fs.existsSync(path.join(projectPath, \"yarn.lock\"))) {\n detectedPM = \"yarn\";\n } else if (fs.existsSync(path.join(projectPath, \"bun.lockb\"))) {\n detectedPM = \"bun\";\n } else {\n detectedPM = \"npm\";\n }\n }\n } else if (fs.existsSync(pyprojectPath) || fs.existsSync(requirementsPath)) {\n detectedLanguage = \"python\";\n\n if (!detectedPM) {\n if (fs.existsSync(pyprojectPath)) {\n const content = fs.readFileSync(pyprojectPath, \"utf-8\");\n if (content.includes(\"poetry\")) {\n detectedPM = \"poetry\";\n } else {\n detectedPM = \"pip\";\n }\n } else {\n detectedPM = \"pip\";\n }\n }\n }\n }\n\n if (!detectedLanguage) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Could not detect project type. Please specify the language parameter (\"typescript\", \"javascript\", or \"python\").`,\n },\n ],\n isError: true,\n };\n }\n\n // Generate install command\n let installCommand: string;\n let packageName: string;\n\n if (detectedLanguage === \"python\") {\n packageName = \"forprompt\";\n switch (detectedPM) {\n case \"poetry\":\n installCommand = `cd \"${projectPath}\" && poetry add ${packageName}`;\n break;\n case \"uv\":\n installCommand = `cd \"${projectPath}\" && uv add ${packageName}`;\n break;\n default:\n installCommand = `cd \"${projectPath}\" && pip install ${packageName}`;\n }\n } else {\n packageName = \"@forprompt/sdk\";\n switch (detectedPM) {\n case \"yarn\":\n installCommand = `cd \"${projectPath}\" && yarn add ${packageName}`;\n break;\n case \"pnpm\":\n installCommand = `cd \"${projectPath}\" && pnpm add ${packageName}`;\n break;\n case \"bun\":\n installCommand = `cd \"${projectPath}\" && bun add ${packageName}`;\n break;\n default:\n installCommand = `cd \"${projectPath}\" && npm install ${packageName}`;\n }\n }\n\n const lines = [\n `# ForPrompt SDK Installation`,\n ``,\n `**Project:** ${projectPath}`,\n `**Language:** ${detectedLanguage}`,\n `**Package Manager:** ${detectedPM}`,\n ``,\n `## Install Command`,\n ``,\n \"```bash\",\n installCommand,\n \"```\",\n ``,\n `**Run this command to install the ForPrompt SDK.**`,\n ``,\n `## After Installation`,\n ``,\n `1. Create a \\`.forprompt\\` config file with your API key`,\n `2. Or set the \\`FORPROMPT_API_KEY\\` environment variable`,\n ``,\n `Use \\`forprompt_generate_config\\` to create the config file automatically.`,\n ];\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: lines.join(\"\\n\"),\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error setting up project: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Generate config file\n server.registerTool(\n \"forprompt_generate_config\",\n {\n description:\n \"Generate a .forprompt configuration file for a project. Returns the config content that should be written to .forprompt file in the project root.\",\n inputSchema: GenerateConfigInputSchema,\n },\n async ({ projectPath, apiKey, baseUrl }) => {\n try {\n const configLines = [\n `# ForPrompt Configuration`,\n `# Generated by ForPrompt MCP Server`,\n ``,\n ];\n\n if (apiKey) {\n configLines.push(`FORPROMPT_API_KEY=${apiKey}`);\n } else {\n configLines.push(`# Add your API key here:`);\n configLines.push(`FORPROMPT_API_KEY=your_api_key_here`);\n }\n\n if (baseUrl) {\n configLines.push(`FORPROMPT_BASE_URL=${baseUrl}`);\n }\n\n const configContent = configLines.join(\"\\n\");\n const configPath = `${projectPath}/.forprompt`;\n\n const lines = [\n `# ForPrompt Configuration`,\n ``,\n `Create a file at \\`${configPath}\\` with the following content:`,\n ``,\n \"```env\",\n configContent,\n \"```\",\n ``,\n `## Alternative: Environment Variables`,\n ``,\n `Instead of a config file, you can set environment variables:`,\n ``,\n \"```bash\",\n `export FORPROMPT_API_KEY=your_api_key_here`,\n \"```\",\n ``,\n `## Get Your API Key`,\n ``,\n `1. Go to https://forprompt.dev/dashboard`,\n `2. Navigate to your organization settings`,\n `3. Create or copy your API key`,\n ``,\n `**Important:** Add \\`.forprompt\\` to your \\`.gitignore\\` to keep your API key secure!`,\n ];\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: lines.join(\"\\n\"),\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error generating config: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Generate example code\n server.registerTool(\n \"forprompt_generate_example\",\n {\n description:\n \"Generate example code showing how to use ForPrompt SDK. Supports different languages and use cases like basic usage, streaming, React hooks, and Next.js API routes.\",\n inputSchema: GenerateExampleInputSchema,\n },\n async ({ language, useCase, promptKey }) => {\n try {\n const key = promptKey || \"my_prompt\";\n let code: string;\n let description: string;\n\n if (language === \"python\") {\n switch (useCase) {\n case \"streaming\":\n description = \"Python streaming example with ForPrompt\";\n code = `from forprompt import ForPrompt\nimport os\n\n# Initialize the client\nclient = ForPrompt(api_key=os.environ.get(\"FORPROMPT_API_KEY\"))\n\n# Get the prompt\nprompt = client.get_prompt(\"${key}\")\n\n# Use with your LLM (example with OpenAI)\nfrom openai import OpenAI\n\nopenai = OpenAI()\n\n# Stream the response\nstream = openai.chat.completions.create(\n model=\"gpt-4\",\n messages=[\n {\"role\": \"system\", \"content\": prompt.system_prompt},\n {\"role\": \"user\", \"content\": \"Your user message here\"}\n ],\n stream=True\n)\n\nfor chunk in stream:\n if chunk.choices[0].delta.content:\n print(chunk.choices[0].delta.content, end=\"\")`;\n break;\n case \"with-tools\":\n description = \"Python example with tools/functions\";\n code = `from forprompt import ForPrompt\nimport os\nimport json\n\nclient = ForPrompt(api_key=os.environ.get(\"FORPROMPT_API_KEY\"))\n\n# Get the prompt with tools\nprompt = client.get_prompt(\"${key}\")\n\n# Define your tools\ntools = [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather for a location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\"type\": \"string\", \"description\": \"City name\"}\n },\n \"required\": [\"location\"]\n }\n }\n }\n]\n\n# Use with OpenAI\nfrom openai import OpenAI\n\nopenai = OpenAI()\n\nresponse = openai.chat.completions.create(\n model=\"gpt-4\",\n messages=[\n {\"role\": \"system\", \"content\": prompt.system_prompt},\n {\"role\": \"user\", \"content\": \"What's the weather in Tokyo?\"}\n ],\n tools=tools,\n tool_choice=\"auto\"\n)\n\nprint(response.choices[0].message)`;\n break;\n default:\n description = \"Basic Python usage example\";\n code = `from forprompt import ForPrompt\nimport os\n\n# Initialize the client\nclient = ForPrompt(api_key=os.environ.get(\"FORPROMPT_API_KEY\"))\n\n# Get a prompt by key\nprompt = client.get_prompt(\"${key}\")\n\nprint(f\"Prompt: {prompt.name}\")\nprint(f\"Version: {prompt.version_number}\")\nprint(f\"System Prompt: {prompt.system_prompt}\")\n\n# Use the prompt with your LLM\nfrom openai import OpenAI\n\nopenai = OpenAI()\n\nresponse = openai.chat.completions.create(\n model=\"gpt-4\",\n messages=[\n {\"role\": \"system\", \"content\": prompt.system_prompt},\n {\"role\": \"user\", \"content\": \"Your user message here\"}\n ]\n)\n\nprint(response.choices[0].message.content)`;\n }\n } else {\n // TypeScript/JavaScript\n const isTS = language === \"typescript\";\n const ext = isTS ? \"ts\" : \"js\";\n\n switch (useCase) {\n case \"streaming\":\n description = \"Streaming example with ForPrompt\";\n code = `import { forprompt } from '@forprompt/sdk';\nimport OpenAI from 'openai';\n\nasync function main() {\n // Get the prompt\n const prompt = await forprompt.getPrompt('${key}');\n\n const openai = new OpenAI();\n\n // Stream the response\n const stream = await openai.chat.completions.create({\n model: 'gpt-4',\n messages: [\n { role: 'system', content: prompt.systemPrompt },\n { role: 'user', content: 'Your user message here' }\n ],\n stream: true,\n });\n\n for await (const chunk of stream) {\n const content = chunk.choices[0]?.delta?.content;\n if (content) process.stdout.write(content);\n }\n}\n\nmain();`;\n break;\n case \"react-hook\":\n description = \"React hook example\";\n code = `import { useState, useEffect } from 'react';\nimport { forprompt } from '@forprompt/sdk';\n${isTS ? \"import type { Prompt } from '@forprompt/sdk';\\n\" : \"\"}\n// Custom hook to fetch a ForPrompt prompt\nexport function usePrompt(key${isTS ? \": string\" : \"\"}) {\n const [prompt, setPrompt] = useState${isTS ? \"<Prompt | null>\" : \"\"}(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState${isTS ? \"<Error | null>\" : \"\"}(null);\n\n useEffect(() => {\n let cancelled = false;\n\n async function fetchPrompt() {\n try {\n setLoading(true);\n const data = await forprompt.getPrompt(key);\n if (!cancelled) {\n setPrompt(data);\n setError(null);\n }\n } catch (err) {\n if (!cancelled) {\n setError(err${isTS ? \" as Error\" : \"\"});\n }\n } finally {\n if (!cancelled) {\n setLoading(false);\n }\n }\n }\n\n fetchPrompt();\n\n return () => { cancelled = true; };\n }, [key]);\n\n return { prompt, loading, error };\n}\n\n// Usage in a component\nfunction ChatComponent() {\n const { prompt, loading, error } = usePrompt('${key}');\n\n if (loading) return <div>Loading prompt...</div>;\n if (error) return <div>Error: {error.message}</div>;\n\n return (\n <div>\n <h1>{prompt${isTS ? \"!\" : \"\"}.name}</h1>\n <p>Version: {prompt${isTS ? \"!\" : \"\"}.versionNumber}</p>\n {/* Use prompt.systemPrompt with your AI chat */}\n </div>\n );\n}`;\n break;\n case \"nextjs-api\":\n description = \"Next.js API route example\";\n code = `// app/api/chat/route.${ext}\nimport { forprompt } from '@forprompt/sdk';\nimport OpenAI from 'openai';\nimport { NextResponse } from 'next/server';\n${isTS ? \"\\nexport const runtime = 'edge';\\n\" : \"\"}\nconst openai = new OpenAI();\n\nexport async function POST(request${isTS ? \": Request\" : \"\"}) {\n try {\n const { message, promptKey } = await request.json();\n\n // Fetch the prompt from ForPrompt\n const prompt = await forprompt.getPrompt(promptKey || '${key}');\n\n // Create completion with the system prompt\n const response = await openai.chat.completions.create({\n model: 'gpt-4',\n messages: [\n { role: 'system', content: prompt.systemPrompt },\n { role: 'user', content: message }\n ],\n });\n\n return NextResponse.json({\n content: response.choices[0].message.content,\n promptVersion: prompt.versionNumber,\n });\n } catch (error) {\n console.error('Chat API error:', error);\n return NextResponse.json(\n { error: 'Failed to process chat request' },\n { status: 500 }\n );\n }\n}`;\n break;\n case \"with-tools\":\n description = \"Example with tools/functions\";\n code = `import { forprompt } from '@forprompt/sdk';\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI();\n\n// Define your tools\nconst tools${isTS ? \": OpenAI.ChatCompletionTool[]\" : \"\"} = [\n {\n type: 'function',\n function: {\n name: 'get_weather',\n description: 'Get current weather for a location',\n parameters: {\n type: 'object',\n properties: {\n location: { type: 'string', description: 'City name' }\n },\n required: ['location']\n }\n }\n }\n];\n\nasync function main() {\n const prompt = await forprompt.getPrompt('${key}');\n\n const response = await openai.chat.completions.create({\n model: 'gpt-4',\n messages: [\n { role: 'system', content: prompt.systemPrompt },\n { role: 'user', content: \"What's the weather in Tokyo?\" }\n ],\n tools,\n tool_choice: 'auto',\n });\n\n console.log(response.choices[0].message);\n}\n\nmain();`;\n break;\n default:\n description = \"Basic usage example\";\n code = `import { forprompt } from '@forprompt/sdk';\nimport OpenAI from 'openai';\n\nasync function main() {\n // Get a prompt by key\n const prompt = await forprompt.getPrompt('${key}');\n\n console.log('Prompt:', prompt.name);\n console.log('Version:', prompt.versionNumber);\n console.log('System Prompt:', prompt.systemPrompt);\n\n // Use with OpenAI\n const openai = new OpenAI();\n\n const response = await openai.chat.completions.create({\n model: 'gpt-4',\n messages: [\n { role: 'system', content: prompt.systemPrompt },\n { role: 'user', content: 'Your user message here' }\n ],\n });\n\n console.log(response.choices[0].message.content);\n}\n\nmain();`;\n }\n }\n\n const lines = [\n `# ${description}`,\n ``,\n `**Language:** ${language}`,\n `**Use Case:** ${useCase}`,\n ``,\n \"```\" + (language === \"python\" ? \"python\" : language),\n code,\n \"```\",\n ``,\n `## Setup Required`,\n ``,\n `1. Install the ForPrompt SDK`,\n `2. Set your \\`FORPROMPT_API_KEY\\` environment variable`,\n `3. Create a prompt with key \\`${key}\\` in ForPrompt dashboard`,\n ];\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: lines.join(\"\\n\"),\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error generating example: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n\n // Tool: Get integration guide\n server.registerTool(\n \"forprompt_integration_guide\",\n {\n description:\n \"Get a step-by-step integration guide for ForPrompt with specific frameworks like Next.js, React, Express, FastAPI, Django, or Flask.\",\n inputSchema: GetIntegrationGuideInputSchema,\n },\n async ({ framework, language }) => {\n try {\n let guide: string;\n\n switch (framework) {\n case \"nextjs\":\n guide = `# ForPrompt + Next.js Integration Guide\n\n## 1. Install the SDK\n\n\\`\\`\\`bash\nnpm install @forprompt/sdk\n# or: pnpm add @forprompt/sdk\n\\`\\`\\`\n\n## 2. Set up environment variables\n\nAdd to your \\`.env.local\\`:\n\n\\`\\`\\`env\nFORPROMPT_API_KEY=your_api_key_here\n\\`\\`\\`\n\n## 3. Create an API route\n\n\\`\\`\\`typescript\n// app/api/chat/route.ts\nimport { forprompt } from '@forprompt/sdk';\nimport { NextResponse } from 'next/server';\n\nexport async function POST(request: Request) {\n const { message, promptKey } = await request.json();\n\n // Fetch prompt from ForPrompt\n const prompt = await forprompt.getPrompt(promptKey);\n\n // Use prompt.systemPrompt with your LLM\n // ... your AI logic here\n\n return NextResponse.json({ response: '...' });\n}\n\\`\\`\\`\n\n## 4. Create a client hook (optional)\n\n\\`\\`\\`typescript\n// hooks/useForPrompt.ts\n'use client';\nimport { forprompt } from '@forprompt/sdk';\nimport { useEffect, useState } from 'react';\n\nexport function usePrompt(key: string) {\n const [prompt, setPrompt] = useState(null);\n\n useEffect(() => {\n forprompt.getPrompt(key).then(setPrompt);\n }, [key]);\n\n return prompt;\n}\n\\`\\`\\`\n\n## 5. Best Practices\n\n- Cache prompts in production using Next.js caching\n- Use server components for initial prompt fetch\n- Consider using SWR or React Query for client-side caching`;\n break;\n\n case \"react\":\n guide = `# ForPrompt + React Integration Guide\n\n## 1. Install the SDK\n\n\\`\\`\\`bash\nnpm install @forprompt/sdk\n\\`\\`\\`\n\n## 2. Create a custom hook\n\n\\`\\`\\`typescript\n// hooks/usePrompt.ts\nimport { useState, useEffect } from 'react';\nimport { forprompt, Prompt } from '@forprompt/sdk';\n\nexport function usePrompt(key: string) {\n const [prompt, setPrompt] = useState<Prompt | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n forprompt.getPrompt(key)\n .then(setPrompt)\n .catch(setError)\n .finally(() => setLoading(false));\n }, [key]);\n\n return { prompt, loading, error };\n}\n\\`\\`\\`\n\n## 3. Use in components\n\n\\`\\`\\`tsx\nfunction ChatBot() {\n const { prompt, loading } = usePrompt('customer_support');\n\n if (loading) return <Spinner />;\n\n return <Chat systemPrompt={prompt.systemPrompt} />;\n}\n\\`\\`\\``;\n break;\n\n case \"express\":\n guide = `# ForPrompt + Express Integration Guide\n\n## 1. Install the SDK\n\n\\`\\`\\`bash\nnpm install @forprompt/sdk\n\\`\\`\\`\n\n## 2. Create a middleware (optional)\n\n\\`\\`\\`typescript\n// middleware/forprompt.ts\nimport { forprompt } from '@forprompt/sdk';\n\nexport async function loadPrompt(req, res, next) {\n try {\n const promptKey = req.query.promptKey || req.body.promptKey;\n if (promptKey) {\n req.prompt = await forprompt.getPrompt(promptKey);\n }\n next();\n } catch (error) {\n next(error);\n }\n}\n\\`\\`\\`\n\n## 3. Use in routes\n\n\\`\\`\\`typescript\nimport express from 'express';\nimport { forprompt } from '@forprompt/sdk';\n\nconst app = express();\n\napp.post('/api/chat', async (req, res) => {\n const { message, promptKey } = req.body;\n\n const prompt = await forprompt.getPrompt(promptKey);\n\n // Use prompt.systemPrompt with your LLM\n // ...\n\n res.json({ response: '...' });\n});\n\\`\\`\\``;\n break;\n\n case \"fastapi\":\n guide = `# ForPrompt + FastAPI Integration Guide\n\n## 1. Install the SDK\n\n\\`\\`\\`bash\npip install forprompt\n\\`\\`\\`\n\n## 2. Create a dependency\n\n\\`\\`\\`python\n# dependencies.py\nfrom forprompt import ForPrompt\nimport os\n\ndef get_forprompt():\n return ForPrompt(api_key=os.environ.get(\"FORPROMPT_API_KEY\"))\n\\`\\`\\`\n\n## 3. Use in routes\n\n\\`\\`\\`python\nfrom fastapi import FastAPI, Depends\nfrom forprompt import ForPrompt\nfrom dependencies import get_forprompt\n\napp = FastAPI()\n\n@app.post(\"/api/chat\")\nasync def chat(\n message: str,\n prompt_key: str,\n fp: ForPrompt = Depends(get_forprompt)\n):\n prompt = fp.get_prompt(prompt_key)\n\n # Use prompt.system_prompt with your LLM\n # ...\n\n return {\"response\": \"...\"}\n\\`\\`\\`\n\n## 4. Best Practices\n\n- Cache prompts using functools.lru_cache or Redis\n- Use async version for better performance\n- Consider using Pydantic models for prompt data`;\n break;\n\n case \"django\":\n guide = `# ForPrompt + Django Integration Guide\n\n## 1. Install the SDK\n\n\\`\\`\\`bash\npip install forprompt\n\\`\\`\\`\n\n## 2. Add to settings\n\n\\`\\`\\`python\n# settings.py\nFORPROMPT_API_KEY = os.environ.get(\"FORPROMPT_API_KEY\")\n\\`\\`\\`\n\n## 3. Create a utility\n\n\\`\\`\\`python\n# utils/forprompt.py\nfrom forprompt import ForPrompt\nfrom django.conf import settings\nfrom functools import lru_cache\n\n@lru_cache(maxsize=100)\ndef get_prompt(key: str):\n client = ForPrompt(api_key=settings.FORPROMPT_API_KEY)\n return client.get_prompt(key)\n\\`\\`\\`\n\n## 4. Use in views\n\n\\`\\`\\`python\nfrom django.http import JsonResponse\nfrom utils.forprompt import get_prompt\n\ndef chat_view(request):\n prompt_key = request.POST.get('prompt_key')\n prompt = get_prompt(prompt_key)\n\n # Use prompt.system_prompt with your LLM\n\n return JsonResponse({\"response\": \"...\"})\n\\`\\`\\``;\n break;\n\n case \"flask\":\n guide = `# ForPrompt + Flask Integration Guide\n\n## 1. Install the SDK\n\n\\`\\`\\`bash\npip install forprompt\n\\`\\`\\`\n\n## 2. Initialize the client\n\n\\`\\`\\`python\n# app.py\nfrom flask import Flask, request, jsonify\nfrom forprompt import ForPrompt\nimport os\n\napp = Flask(__name__)\nforprompt_client = ForPrompt(api_key=os.environ.get(\"FORPROMPT_API_KEY\"))\n\n@app.route('/api/chat', methods=['POST'])\ndef chat():\n data = request.json\n prompt = forprompt_client.get_prompt(data['prompt_key'])\n\n # Use prompt.system_prompt with your LLM\n\n return jsonify({\"response\": \"...\"})\n\\`\\`\\``;\n break;\n\n default:\n guide = `# ForPrompt Generic Integration Guide\n\n## TypeScript/JavaScript\n\n\\`\\`\\`typescript\nimport { forprompt } from '@forprompt/sdk';\n\nconst prompt = await forprompt.getPrompt('your_prompt_key');\nconsole.log(prompt.systemPrompt);\n\\`\\`\\`\n\n## Python\n\n\\`\\`\\`python\nfrom forprompt import ForPrompt\nimport os\n\nclient = ForPrompt(api_key=os.environ.get(\"FORPROMPT_API_KEY\"))\nprompt = client.get_prompt(\"your_prompt_key\")\nprint(prompt.system_prompt)\n\\`\\`\\`\n\n## Environment Setup\n\n1. Get your API key from https://forprompt.dev/dashboard\n2. Set \\`FORPROMPT_API_KEY\\` environment variable\n3. Install the SDK for your language\n4. Start fetching prompts!`;\n }\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: guide,\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error generating guide: ${message}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n}\n","/**\n * MCP Resource Handlers\n *\n * Exposes ForPrompt prompts as MCP resources that AI assistants can read.\n */\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ForPrompt } from \"../client.js\";\nimport type { ForPromptMcpServerConfig } from \"./server.js\";\nimport type { Prompt, SyncResponse } from \"../types.js\";\n\nconst DEFAULT_BASE_URL = \"https://wooden-fox-811.convex.site\";\n\n/**\n * Fetch all prompts using the sync endpoint\n */\nasync function fetchAllPrompts(\n config: ForPromptMcpServerConfig\n): Promise<Prompt[]> {\n const apiKey = config.apiKey || process.env.FORPROMPT_API_KEY;\n const baseUrl = (\n config.baseUrl ||\n process.env.FORPROMPT_BASE_URL ||\n DEFAULT_BASE_URL\n ).replace(/\\/$/, \"\");\n\n if (!apiKey) {\n throw new Error(\n \"API key is required. Set FORPROMPT_API_KEY environment variable.\"\n );\n }\n\n const response = await fetch(`${baseUrl}/api/sync`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({\n error: \"Unknown error\",\n }))) as { error?: string };\n throw new Error(errorData.error || `Failed to fetch prompts`);\n }\n\n const data = (await response.json()) as SyncResponse;\n return data.prompts;\n}\n\n/**\n * Parse a forprompt:// URI and extract components\n */\nfunction parseUri(uri: string): {\n key?: string;\n version?: number;\n type: \"list\" | \"prompt\" | \"metadata\";\n} {\n // forprompt://prompts -> list all\n // forprompt://prompts/{key} -> single prompt\n // forprompt://prompts/{key}/v{number} -> specific version\n // forprompt://prompts/{key}/metadata -> metadata only\n\n const match = uri.match(/^forprompt:\\/\\/prompts(?:\\/([^/]+))?(?:\\/(v\\d+|metadata))?$/);\n\n if (!match) {\n return { type: \"list\" };\n }\n\n const [, key, suffix] = match;\n\n if (!key) {\n return { type: \"list\" };\n }\n\n if (suffix === \"metadata\") {\n return { key, type: \"metadata\" };\n }\n\n if (suffix?.startsWith(\"v\")) {\n const version = parseInt(suffix.slice(1), 10);\n return { key, version, type: \"prompt\" };\n }\n\n return { key, type: \"prompt\" };\n}\n\n/**\n * Format a prompt as resource content\n */\nfunction formatPromptResource(prompt: Prompt): string {\n const sections: string[] = [];\n\n sections.push(`# ${prompt.name}`);\n sections.push(\"\");\n sections.push(`Key: ${prompt.key}`);\n sections.push(`Version: ${prompt.versionNumber}`);\n sections.push(`Updated: ${new Date(prompt.updatedAt).toISOString()}`);\n\n if (prompt.description) {\n sections.push(\"\");\n sections.push(`## Description`);\n sections.push(prompt.description);\n }\n\n sections.push(\"\");\n sections.push(\"## System Prompt\");\n sections.push(\"\");\n sections.push(prompt.systemPrompt);\n\n if (prompt.purpose) {\n sections.push(\"\");\n sections.push(\"## Purpose\");\n sections.push(prompt.purpose);\n }\n\n if (prompt.expectedBehavior) {\n sections.push(\"\");\n sections.push(\"## Expected Behavior\");\n sections.push(prompt.expectedBehavior);\n }\n\n if (prompt.inputFormat) {\n sections.push(\"\");\n sections.push(\"## Input Format\");\n sections.push(prompt.inputFormat);\n }\n\n if (prompt.outputFormat) {\n sections.push(\"\");\n sections.push(\"## Output Format\");\n sections.push(prompt.outputFormat);\n }\n\n if (prompt.constraints) {\n sections.push(\"\");\n sections.push(\"## Constraints\");\n sections.push(prompt.constraints);\n }\n\n if (prompt.useCases) {\n sections.push(\"\");\n sections.push(\"## Use Cases\");\n sections.push(prompt.useCases);\n }\n\n return sections.join(\"\\n\");\n}\n\n/**\n * Register MCP resources\n */\nexport function registerResources(\n server: McpServer,\n client: ForPrompt,\n config: ForPromptMcpServerConfig\n): void {\n // Resource template for prompts\n server.resource(\n \"forprompt://prompts/{key}\",\n \"Access a ForPrompt prompt by its key. Returns the system prompt and all metadata.\",\n async (uri) => {\n const parsed = parseUri(uri.href);\n\n if (parsed.type === \"list\" || !parsed.key) {\n // Return list of all prompts\n const prompts = await fetchAllPrompts(config);\n const list = prompts\n .map((p) => `- ${p.key}: ${p.name} (v${p.versionNumber})`)\n .join(\"\\n\");\n\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: \"text/plain\",\n text: `# ForPrompt Prompts\\n\\n${prompts.length} prompt(s) available:\\n\\n${list}`,\n },\n ],\n };\n }\n\n if (parsed.type === \"metadata\") {\n // Return metadata only\n const prompt = await client.getPrompt(parsed.key);\n const metadata = {\n key: prompt.key,\n name: prompt.name,\n description: prompt.description,\n versionNumber: prompt.versionNumber,\n updatedAt: prompt.updatedAt,\n purpose: prompt.purpose,\n expectedBehavior: prompt.expectedBehavior,\n inputFormat: prompt.inputFormat,\n outputFormat: prompt.outputFormat,\n constraints: prompt.constraints,\n useCases: prompt.useCases,\n };\n\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: \"application/json\",\n text: JSON.stringify(metadata, null, 2),\n },\n ],\n };\n }\n\n // Return full prompt\n const prompt = await client.getPrompt(parsed.key, {\n version: parsed.version,\n });\n\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: \"text/plain\",\n text: formatPromptResource(prompt),\n },\n ],\n };\n }\n );\n}\n","{\n \"name\": \"@forprompt/sdk\",\n \"version\": \"0.1.0\",\n \"description\": \"ForPrompt SDK - Sync and manage AI prompts from your ForPrompt projects\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"forprompt\": \"./dist/cli/index.js\",\n \"forprompt-mcp\": \"./dist/mcp/server.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./mcp\": {\n \"types\": \"./dist/mcp/index.d.ts\",\n \"import\": \"./dist/mcp/index.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"license\": \"AGPL-3.0-or-later\",\n \"author\": \"ForPrompt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/ardacanuckan/forprompt.git\",\n \"directory\": \"packages/sdk\"\n },\n \"homepage\": \"https://forprompt.dev\",\n \"bugs\": {\n \"url\": \"https://github.com/forprompt/sdk/issues\"\n },\n \"keywords\": [\n \"forprompt\",\n \"prompts\",\n \"ai\",\n \"llm\",\n \"prompt-management\",\n \"cli\",\n \"sdk\",\n \"openai\",\n \"anthropic\",\n \"chatgpt\"\n ],\n \"engines\": {\n \"node\": \">=18.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"prepublishOnly\": \"pnpm run typecheck && pnpm run build\",\n \"prepack\": \"pnpm run build\",\n \"clean\": \"rm -rf dist node_modules coverage\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint src/\",\n \"test\": \"echo 'Tests temporarily disabled due to Vitest/ESM configuration issue. Tests are written and ready in src/__tests__/' && exit 0\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.0.0\",\n \"zod\": \"^3.24.0\"\n },\n \"devDependencies\": {\n \"@forprompt/eslint-config\": \"workspace:*\",\n \"@forprompt/tsconfig\": \"workspace:*\",\n \"@types/node\": \"^20.0.0\",\n \"@vitest/coverage-v8\": \"^2.1.0\",\n \"eslint\": \"^9.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.3.0\",\n \"vitest\": \"^2.1.0\"\n }\n}\n","/**\n * Version management - reads from package.json at build time\n * \n * This file provides the SDK version dynamically from package.json\n * to avoid hardcoded version strings that need manual updates.\n */\n\n// @ts-ignore - package.json is resolved at build time\nimport pkg from \"../package.json\" with { type: \"json\" };\n\n/**\n * The current SDK version from package.json\n */\nexport const VERSION = pkg.version as string;\n"],"mappings":";AAYA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACmD9B,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACE,SACO,YACA,MACP;AACA,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;;;ACzDA,IAAM,mBAAmB;AACzB,IAAM,kBAA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AA;AAAA;AAAA;AAAA,EAKA,YAAuB;AACrB,WAAO,KAAK;AAAA,EACd;AACF;AAKA,eAAsB,eACpB,SAAmC,CAAC,GACP;AAC7B,QAAM,SAAS,IAAI,mBAAmB,MAAM;AAC5C,QAAM,OAAO,MAAM;AACnB,SAAO;AACT;AAIA,SAAS,eAAwB;AAC/B,QAAM,OAAO,QAAQ,KAAK,CAAC,KAAK;AAChC,SACE,KAAK,SAAS,eAAe,KAC7B,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY;AAE9B;AAEA,IAAI,aAAa,GAAG;AAClB,iBAAe,EAAE,MAAM,CAAC,UAAU;AAChC,YAAQ,MAAM,+BAA+B,KAAK;AAClD,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;","names":["DEFAULT_BASE_URL","DEFAULT_BASE_URL","fetchAllPrompts","prompt"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { ForPromptMcpServer, ForPromptMcpServerConfig, startMcpServer } from './server.js';
|
|
2
|
+
import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MCP Configuration Generators
|
|
6
|
+
*
|
|
7
|
+
* Generate configuration files for various AI editors and tools
|
|
8
|
+
* to connect to the ForPrompt MCP server.
|
|
9
|
+
*/
|
|
10
|
+
type SupportedEditor = "claude-desktop" | "claude-code" | "cursor" | "continue" | "windsurf" | "vscode";
|
|
11
|
+
interface EditorConfig {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
configPath: string;
|
|
15
|
+
configFileName: string;
|
|
16
|
+
generate: (apiKey: string, baseUrl?: string) => string;
|
|
17
|
+
instructions: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Generate configuration for a specific editor
|
|
21
|
+
*/
|
|
22
|
+
declare function generateConfig(editor: SupportedEditor, apiKey: string, baseUrl?: string): {
|
|
23
|
+
config: string;
|
|
24
|
+
path: string;
|
|
25
|
+
instructions: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get the config path for an editor
|
|
29
|
+
*/
|
|
30
|
+
declare function getConfigPath(editor: SupportedEditor): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get list of supported editors
|
|
33
|
+
*/
|
|
34
|
+
declare function getSupportedEditors(): SupportedEditor[];
|
|
35
|
+
|
|
36
|
+
export { type EditorConfig, type SupportedEditor, generateConfig, getConfigPath, getSupportedEditors };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ForPromptMcpServer,
|
|
3
|
+
startMcpServer
|
|
4
|
+
} from "./chunk-2ABKAGKB.js";
|
|
5
|
+
|
|
6
|
+
// src/mcp/config/generators.ts
|
|
7
|
+
import * as os from "os";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
function getEditorConfigPath(editor) {
|
|
10
|
+
const home = os.homedir();
|
|
11
|
+
switch (editor) {
|
|
12
|
+
case "claude-desktop":
|
|
13
|
+
if (process.platform === "darwin") {
|
|
14
|
+
return path.join(
|
|
15
|
+
home,
|
|
16
|
+
"Library",
|
|
17
|
+
"Application Support",
|
|
18
|
+
"Claude",
|
|
19
|
+
"claude_desktop_config.json"
|
|
20
|
+
);
|
|
21
|
+
} else if (process.platform === "win32") {
|
|
22
|
+
return path.join(
|
|
23
|
+
process.env.APPDATA || path.join(home, "AppData", "Roaming"),
|
|
24
|
+
"Claude",
|
|
25
|
+
"claude_desktop_config.json"
|
|
26
|
+
);
|
|
27
|
+
} else {
|
|
28
|
+
return path.join(home, ".config", "Claude", "claude_desktop_config.json");
|
|
29
|
+
}
|
|
30
|
+
case "claude-code":
|
|
31
|
+
return path.join(process.cwd(), ".mcp.json");
|
|
32
|
+
case "cursor":
|
|
33
|
+
return path.join(process.cwd(), ".cursor", "mcp.json");
|
|
34
|
+
case "continue":
|
|
35
|
+
return path.join(home, ".continue", "config.json");
|
|
36
|
+
case "windsurf":
|
|
37
|
+
return path.join(home, ".windsurf", "mcp.json");
|
|
38
|
+
case "vscode":
|
|
39
|
+
return path.join(process.cwd(), ".vscode", "mcp.json");
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Unknown editor: ${editor}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function generateClaudeDesktopConfig(apiKey, baseUrl) {
|
|
45
|
+
const config = {
|
|
46
|
+
mcpServers: {
|
|
47
|
+
forprompt: {
|
|
48
|
+
command: "npx",
|
|
49
|
+
args: ["-y", "@forprompt/sdk", "mcp", "start"],
|
|
50
|
+
env: {
|
|
51
|
+
FORPROMPT_API_KEY: apiKey,
|
|
52
|
+
...baseUrl && { FORPROMPT_BASE_URL: baseUrl }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return JSON.stringify(config, null, 2);
|
|
58
|
+
}
|
|
59
|
+
function generateClaudeCodeConfig(apiKey, baseUrl) {
|
|
60
|
+
const config = {
|
|
61
|
+
mcpServers: {
|
|
62
|
+
forprompt: {
|
|
63
|
+
command: "npx",
|
|
64
|
+
args: ["-y", "@forprompt/sdk", "mcp", "start"],
|
|
65
|
+
env: {
|
|
66
|
+
FORPROMPT_API_KEY: apiKey,
|
|
67
|
+
...baseUrl && { FORPROMPT_BASE_URL: baseUrl }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return JSON.stringify(config, null, 2);
|
|
73
|
+
}
|
|
74
|
+
function generateCursorConfig(apiKey, baseUrl) {
|
|
75
|
+
const config = {
|
|
76
|
+
mcpServers: {
|
|
77
|
+
forprompt: {
|
|
78
|
+
command: "npx",
|
|
79
|
+
args: ["-y", "@forprompt/sdk", "mcp", "start"],
|
|
80
|
+
env: {
|
|
81
|
+
FORPROMPT_API_KEY: apiKey,
|
|
82
|
+
...baseUrl && { FORPROMPT_BASE_URL: baseUrl }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return JSON.stringify(config, null, 2);
|
|
88
|
+
}
|
|
89
|
+
function generateContinueConfig(apiKey, baseUrl) {
|
|
90
|
+
const config = {
|
|
91
|
+
mcpServers: [
|
|
92
|
+
{
|
|
93
|
+
name: "forprompt",
|
|
94
|
+
command: "npx",
|
|
95
|
+
args: ["-y", "@forprompt/sdk", "mcp", "start"],
|
|
96
|
+
env: {
|
|
97
|
+
FORPROMPT_API_KEY: apiKey,
|
|
98
|
+
...baseUrl && { FORPROMPT_BASE_URL: baseUrl }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
return JSON.stringify(config, null, 2);
|
|
104
|
+
}
|
|
105
|
+
function generateWindsurfConfig(apiKey, baseUrl) {
|
|
106
|
+
const config = {
|
|
107
|
+
mcpServers: {
|
|
108
|
+
forprompt: {
|
|
109
|
+
command: "npx",
|
|
110
|
+
args: ["-y", "@forprompt/sdk", "mcp", "start"],
|
|
111
|
+
env: {
|
|
112
|
+
FORPROMPT_API_KEY: apiKey,
|
|
113
|
+
...baseUrl && { FORPROMPT_BASE_URL: baseUrl }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return JSON.stringify(config, null, 2);
|
|
119
|
+
}
|
|
120
|
+
function generateVSCodeConfig(apiKey, baseUrl) {
|
|
121
|
+
const config = {
|
|
122
|
+
mcpServers: {
|
|
123
|
+
forprompt: {
|
|
124
|
+
command: "npx",
|
|
125
|
+
args: ["-y", "@forprompt/sdk", "mcp", "start"],
|
|
126
|
+
env: {
|
|
127
|
+
FORPROMPT_API_KEY: apiKey,
|
|
128
|
+
...baseUrl && { FORPROMPT_BASE_URL: baseUrl }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return JSON.stringify(config, null, 2);
|
|
134
|
+
}
|
|
135
|
+
var editorConfigs = {
|
|
136
|
+
"claude-desktop": {
|
|
137
|
+
name: "Claude Desktop",
|
|
138
|
+
description: "Anthropic's Claude desktop application",
|
|
139
|
+
configPath: getEditorConfigPath("claude-desktop"),
|
|
140
|
+
configFileName: "claude_desktop_config.json",
|
|
141
|
+
generate: generateClaudeDesktopConfig,
|
|
142
|
+
instructions: `
|
|
143
|
+
1. Open the config file at the path shown above
|
|
144
|
+
2. Add or merge the ForPrompt MCP server configuration
|
|
145
|
+
3. Restart Claude Desktop
|
|
146
|
+
4. You can now ask Claude to "list my ForPrompt prompts" or "get the [prompt-key] prompt"
|
|
147
|
+
`
|
|
148
|
+
},
|
|
149
|
+
"claude-code": {
|
|
150
|
+
name: "Claude Code",
|
|
151
|
+
description: "Anthropic's Claude Code CLI tool",
|
|
152
|
+
configPath: getEditorConfigPath("claude-code"),
|
|
153
|
+
configFileName: ".mcp.json",
|
|
154
|
+
generate: generateClaudeCodeConfig,
|
|
155
|
+
instructions: `
|
|
156
|
+
1. Create .mcp.json in your project root directory
|
|
157
|
+
2. Add the ForPrompt MCP server configuration
|
|
158
|
+
3. Claude Code will automatically detect and load the MCP server
|
|
159
|
+
4. You can now ask Claude Code to manage your ForPrompt prompts
|
|
160
|
+
`
|
|
161
|
+
},
|
|
162
|
+
cursor: {
|
|
163
|
+
name: "Cursor",
|
|
164
|
+
description: "Cursor AI-powered code editor",
|
|
165
|
+
configPath: getEditorConfigPath("cursor"),
|
|
166
|
+
configFileName: "mcp.json",
|
|
167
|
+
generate: generateCursorConfig,
|
|
168
|
+
instructions: `
|
|
169
|
+
1. Create the .cursor directory in your project root if it doesn't exist
|
|
170
|
+
2. Save the configuration to .cursor/mcp.json
|
|
171
|
+
3. Restart Cursor or reload the window
|
|
172
|
+
4. Your ForPrompt prompts will be available via MCP
|
|
173
|
+
`
|
|
174
|
+
},
|
|
175
|
+
continue: {
|
|
176
|
+
name: "Continue.dev",
|
|
177
|
+
description: "Continue - open-source AI code assistant",
|
|
178
|
+
configPath: getEditorConfigPath("continue"),
|
|
179
|
+
configFileName: "config.json",
|
|
180
|
+
generate: generateContinueConfig,
|
|
181
|
+
instructions: `
|
|
182
|
+
1. Open your Continue config file (~/.continue/config.json)
|
|
183
|
+
2. Add the ForPrompt MCP server to the mcpServers array
|
|
184
|
+
3. Restart your IDE or reload Continue
|
|
185
|
+
4. Your ForPrompt prompts will be available via MCP
|
|
186
|
+
`
|
|
187
|
+
},
|
|
188
|
+
windsurf: {
|
|
189
|
+
name: "Windsurf",
|
|
190
|
+
description: "Windsurf AI-powered IDE",
|
|
191
|
+
configPath: getEditorConfigPath("windsurf"),
|
|
192
|
+
configFileName: "mcp.json",
|
|
193
|
+
generate: generateWindsurfConfig,
|
|
194
|
+
instructions: `
|
|
195
|
+
1. Create the ~/.windsurf directory if it doesn't exist
|
|
196
|
+
2. Save the configuration to ~/.windsurf/mcp.json
|
|
197
|
+
3. Restart Windsurf
|
|
198
|
+
4. Your ForPrompt prompts will be available via MCP
|
|
199
|
+
`
|
|
200
|
+
},
|
|
201
|
+
vscode: {
|
|
202
|
+
name: "VS Code",
|
|
203
|
+
description: "Visual Studio Code with MCP extension",
|
|
204
|
+
configPath: getEditorConfigPath("vscode"),
|
|
205
|
+
configFileName: "mcp.json",
|
|
206
|
+
generate: generateVSCodeConfig,
|
|
207
|
+
instructions: `
|
|
208
|
+
1. Install an MCP-compatible extension in VS Code
|
|
209
|
+
2. Create .vscode/mcp.json in your project
|
|
210
|
+
3. Add the ForPrompt MCP server configuration
|
|
211
|
+
4. Reload VS Code
|
|
212
|
+
`
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
function generateConfig(editor, apiKey, baseUrl) {
|
|
216
|
+
const editorConfig = editorConfigs[editor];
|
|
217
|
+
if (!editorConfig) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Unknown editor: ${editor}. Supported editors: ${getSupportedEditors().join(", ")}`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
config: editorConfig.generate(apiKey, baseUrl),
|
|
224
|
+
path: editorConfig.configPath,
|
|
225
|
+
instructions: editorConfig.instructions
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function getConfigPath(editor) {
|
|
229
|
+
return editorConfigs[editor]?.configPath || "";
|
|
230
|
+
}
|
|
231
|
+
function getSupportedEditors() {
|
|
232
|
+
return Object.keys(editorConfigs);
|
|
233
|
+
}
|
|
234
|
+
export {
|
|
235
|
+
ForPromptMcpServer,
|
|
236
|
+
generateConfig,
|
|
237
|
+
getConfigPath,
|
|
238
|
+
getSupportedEditors,
|
|
239
|
+
startMcpServer
|
|
240
|
+
};
|
|
241
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/config/generators.ts"],"sourcesContent":["/**\n * MCP Configuration Generators\n *\n * Generate configuration files for various AI editors and tools\n * to connect to the ForPrompt MCP server.\n */\n\nimport * as os from \"os\";\nimport * as path from \"path\";\n\nexport type SupportedEditor =\n | \"claude-desktop\"\n | \"claude-code\"\n | \"cursor\"\n | \"continue\"\n | \"windsurf\"\n | \"vscode\";\n\nexport interface EditorConfig {\n name: string;\n description: string;\n configPath: string;\n configFileName: string;\n generate: (apiKey: string, baseUrl?: string) => string;\n instructions: string;\n}\n\n/**\n * Get the config file path for an editor\n */\nfunction getEditorConfigPath(editor: SupportedEditor): string {\n const home = os.homedir();\n\n switch (editor) {\n case \"claude-desktop\":\n if (process.platform === \"darwin\") {\n return path.join(\n home,\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n } else if (process.platform === \"win32\") {\n return path.join(\n process.env.APPDATA || path.join(home, \"AppData\", \"Roaming\"),\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n } else {\n return path.join(home, \".config\", \"Claude\", \"claude_desktop_config.json\");\n }\n\n case \"claude-code\":\n return path.join(process.cwd(), \".mcp.json\");\n\n case \"cursor\":\n return path.join(process.cwd(), \".cursor\", \"mcp.json\");\n\n case \"continue\":\n return path.join(home, \".continue\", \"config.json\");\n\n case \"windsurf\":\n return path.join(home, \".windsurf\", \"mcp.json\");\n\n case \"vscode\":\n return path.join(process.cwd(), \".vscode\", \"mcp.json\");\n\n default:\n throw new Error(`Unknown editor: ${editor}`);\n }\n}\n\n/**\n * Generate MCP server configuration for Claude Desktop\n */\nfunction generateClaudeDesktopConfig(apiKey: string, baseUrl?: string): string {\n const config = {\n mcpServers: {\n forprompt: {\n command: \"npx\",\n args: [\"-y\", \"@forprompt/sdk\", \"mcp\", \"start\"],\n env: {\n FORPROMPT_API_KEY: apiKey,\n ...(baseUrl && { FORPROMPT_BASE_URL: baseUrl }),\n },\n },\n },\n };\n\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Generate MCP server configuration for Claude Code\n */\nfunction generateClaudeCodeConfig(apiKey: string, baseUrl?: string): string {\n const config = {\n mcpServers: {\n forprompt: {\n command: \"npx\",\n args: [\"-y\", \"@forprompt/sdk\", \"mcp\", \"start\"],\n env: {\n FORPROMPT_API_KEY: apiKey,\n ...(baseUrl && { FORPROMPT_BASE_URL: baseUrl }),\n },\n },\n },\n };\n\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Generate MCP server configuration for Cursor\n */\nfunction generateCursorConfig(apiKey: string, baseUrl?: string): string {\n const config = {\n mcpServers: {\n forprompt: {\n command: \"npx\",\n args: [\"-y\", \"@forprompt/sdk\", \"mcp\", \"start\"],\n env: {\n FORPROMPT_API_KEY: apiKey,\n ...(baseUrl && { FORPROMPT_BASE_URL: baseUrl }),\n },\n },\n },\n };\n\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Generate MCP server configuration for Continue.dev\n */\nfunction generateContinueConfig(apiKey: string, baseUrl?: string): string {\n const config = {\n mcpServers: [\n {\n name: \"forprompt\",\n command: \"npx\",\n args: [\"-y\", \"@forprompt/sdk\", \"mcp\", \"start\"],\n env: {\n FORPROMPT_API_KEY: apiKey,\n ...(baseUrl && { FORPROMPT_BASE_URL: baseUrl }),\n },\n },\n ],\n };\n\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Generate MCP server configuration for Windsurf\n */\nfunction generateWindsurfConfig(apiKey: string, baseUrl?: string): string {\n const config = {\n mcpServers: {\n forprompt: {\n command: \"npx\",\n args: [\"-y\", \"@forprompt/sdk\", \"mcp\", \"start\"],\n env: {\n FORPROMPT_API_KEY: apiKey,\n ...(baseUrl && { FORPROMPT_BASE_URL: baseUrl }),\n },\n },\n },\n };\n\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Generate MCP server configuration for VS Code\n */\nfunction generateVSCodeConfig(apiKey: string, baseUrl?: string): string {\n const config = {\n mcpServers: {\n forprompt: {\n command: \"npx\",\n args: [\"-y\", \"@forprompt/sdk\", \"mcp\", \"start\"],\n env: {\n FORPROMPT_API_KEY: apiKey,\n ...(baseUrl && { FORPROMPT_BASE_URL: baseUrl }),\n },\n },\n },\n };\n\n return JSON.stringify(config, null, 2);\n}\n\n/**\n * Editor configurations\n */\nexport const editorConfigs: Record<SupportedEditor, EditorConfig> = {\n \"claude-desktop\": {\n name: \"Claude Desktop\",\n description: \"Anthropic's Claude desktop application\",\n configPath: getEditorConfigPath(\"claude-desktop\"),\n configFileName: \"claude_desktop_config.json\",\n generate: generateClaudeDesktopConfig,\n instructions: `\n1. Open the config file at the path shown above\n2. Add or merge the ForPrompt MCP server configuration\n3. Restart Claude Desktop\n4. You can now ask Claude to \"list my ForPrompt prompts\" or \"get the [prompt-key] prompt\"\n`,\n },\n\n \"claude-code\": {\n name: \"Claude Code\",\n description: \"Anthropic's Claude Code CLI tool\",\n configPath: getEditorConfigPath(\"claude-code\"),\n configFileName: \".mcp.json\",\n generate: generateClaudeCodeConfig,\n instructions: `\n1. Create .mcp.json in your project root directory\n2. Add the ForPrompt MCP server configuration\n3. Claude Code will automatically detect and load the MCP server\n4. You can now ask Claude Code to manage your ForPrompt prompts\n`,\n },\n\n cursor: {\n name: \"Cursor\",\n description: \"Cursor AI-powered code editor\",\n configPath: getEditorConfigPath(\"cursor\"),\n configFileName: \"mcp.json\",\n generate: generateCursorConfig,\n instructions: `\n1. Create the .cursor directory in your project root if it doesn't exist\n2. Save the configuration to .cursor/mcp.json\n3. Restart Cursor or reload the window\n4. Your ForPrompt prompts will be available via MCP\n`,\n },\n\n continue: {\n name: \"Continue.dev\",\n description: \"Continue - open-source AI code assistant\",\n configPath: getEditorConfigPath(\"continue\"),\n configFileName: \"config.json\",\n generate: generateContinueConfig,\n instructions: `\n1. Open your Continue config file (~/.continue/config.json)\n2. Add the ForPrompt MCP server to the mcpServers array\n3. Restart your IDE or reload Continue\n4. Your ForPrompt prompts will be available via MCP\n`,\n },\n\n windsurf: {\n name: \"Windsurf\",\n description: \"Windsurf AI-powered IDE\",\n configPath: getEditorConfigPath(\"windsurf\"),\n configFileName: \"mcp.json\",\n generate: generateWindsurfConfig,\n instructions: `\n1. Create the ~/.windsurf directory if it doesn't exist\n2. Save the configuration to ~/.windsurf/mcp.json\n3. Restart Windsurf\n4. Your ForPrompt prompts will be available via MCP\n`,\n },\n\n vscode: {\n name: \"VS Code\",\n description: \"Visual Studio Code with MCP extension\",\n configPath: getEditorConfigPath(\"vscode\"),\n configFileName: \"mcp.json\",\n generate: generateVSCodeConfig,\n instructions: `\n1. Install an MCP-compatible extension in VS Code\n2. Create .vscode/mcp.json in your project\n3. Add the ForPrompt MCP server configuration\n4. Reload VS Code\n`,\n },\n};\n\n/**\n * Generate configuration for a specific editor\n */\nexport function generateConfig(\n editor: SupportedEditor,\n apiKey: string,\n baseUrl?: string\n): { config: string; path: string; instructions: string } {\n const editorConfig = editorConfigs[editor];\n\n if (!editorConfig) {\n throw new Error(\n `Unknown editor: ${editor}. Supported editors: ${getSupportedEditors().join(\", \")}`\n );\n }\n\n return {\n config: editorConfig.generate(apiKey, baseUrl),\n path: editorConfig.configPath,\n instructions: editorConfig.instructions,\n };\n}\n\n/**\n * Get the config path for an editor\n */\nexport function getConfigPath(editor: SupportedEditor): string {\n return editorConfigs[editor]?.configPath || \"\";\n}\n\n/**\n * Get list of supported editors\n */\nexport function getSupportedEditors(): SupportedEditor[] {\n return Object.keys(editorConfigs) as SupportedEditor[];\n}\n"],"mappings":";;;;;;AAOA,YAAY,QAAQ;AACpB,YAAY,UAAU;AAsBtB,SAAS,oBAAoB,QAAiC;AAC5D,QAAM,OAAU,WAAQ;AAExB,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,UAAI,QAAQ,aAAa,UAAU;AACjC,eAAY;AAAA,UACV;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,WAAW,QAAQ,aAAa,SAAS;AACvC,eAAY;AAAA,UACV,QAAQ,IAAI,WAAgB,UAAK,MAAM,WAAW,SAAS;AAAA,UAC3D;AAAA,UACA;AAAA,QACF;AAAA,MACF,OAAO;AACL,eAAY,UAAK,MAAM,WAAW,UAAU,4BAA4B;AAAA,MAC1E;AAAA,IAEF,KAAK;AACH,aAAY,UAAK,QAAQ,IAAI,GAAG,WAAW;AAAA,IAE7C,KAAK;AACH,aAAY,UAAK,QAAQ,IAAI,GAAG,WAAW,UAAU;AAAA,IAEvD,KAAK;AACH,aAAY,UAAK,MAAM,aAAa,aAAa;AAAA,IAEnD,KAAK;AACH,aAAY,UAAK,MAAM,aAAa,UAAU;AAAA,IAEhD,KAAK;AACH,aAAY,UAAK,QAAQ,IAAI,GAAG,WAAW,UAAU;AAAA,IAEvD;AACE,YAAM,IAAI,MAAM,mBAAmB,MAAM,EAAE;AAAA,EAC/C;AACF;AAKA,SAAS,4BAA4B,QAAgB,SAA0B;AAC7E,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,WAAW;AAAA,QACT,SAAS;AAAA,QACT,MAAM,CAAC,MAAM,kBAAkB,OAAO,OAAO;AAAA,QAC7C,KAAK;AAAA,UACH,mBAAmB;AAAA,UACnB,GAAI,WAAW,EAAE,oBAAoB,QAAQ;AAAA,QAC/C;AAAA,MACF;AAAA,IACF;A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AAAA;AAAA;AAAA,EAMhB;AAAA,EAEA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY,oBAAoB,UAAU;AAAA,IAC1C,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhB;AAAA,EAEA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY,oBAAoB,QAAQ;AAAA,IACxC,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhB;AACF;AAKO,SAAS,eACd,QACA,QACA,SACwD;AACxD,QAAM,eAAe,cAAc,MAAM;AAEzC,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR,mBAAmB,MAAM,wBAAwB,oBAAoB,EAAE,KAAK,IAAI,CAAC;AAAA,IACnF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAQ,aAAa,SAAS,QAAQ,OAAO;AAAA,IAC7C,MAAM,aAAa;AAAA,IACnB,cAAc,aAAa;AAAA,EAC7B;AACF;AAKO,SAAS,cAAc,QAAiC;AAC7D,SAAO,cAAc,MAAM,GAAG,cAAc;AAC9C;AAKO,SAAS,sBAAyC;AACvD,SAAO,OAAO,KAAK,aAAa;AAClC;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ForPrompt MCP Server
|
|
6
|
+
*
|
|
7
|
+
* Model Context Protocol server that exposes ForPrompt prompts as
|
|
8
|
+
* resources and tools for AI assistants like Claude, Cursor, and Continue.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* npx forprompt mcp start
|
|
12
|
+
* FORPROMPT_API_KEY=fp_xxx npx forprompt-mcp
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface ForPromptMcpServerConfig {
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
declare class ForPromptMcpServer {
|
|
20
|
+
private mcpServer;
|
|
21
|
+
private forprompt;
|
|
22
|
+
private config;
|
|
23
|
+
constructor(config?: ForPromptMcpServerConfig);
|
|
24
|
+
private registerCapabilities;
|
|
25
|
+
/**
|
|
26
|
+
* Start the MCP server with stdio transport
|
|
27
|
+
*/
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the underlying MCP server instance
|
|
31
|
+
*/
|
|
32
|
+
getServer(): McpServer;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create and start an MCP server
|
|
36
|
+
*/
|
|
37
|
+
declare function startMcpServer(config?: ForPromptMcpServerConfig): Promise<ForPromptMcpServer>;
|
|
38
|
+
|
|
39
|
+
export { ForPromptMcpServer, type ForPromptMcpServerConfig, startMcpServer };
|