import Link from "next/link"; import { headers } from "next/headers"; import { Code, Zap, Terminal, Search, Box, Key, Save } from "lucide-react"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { McpConfigTabs } from "@/components/mcp/mcp-config-tabs"; export const metadata = { title: "API Documentation - prompts.chat", description: "MCP-first API for searching and discovering AI prompts programmatically", }; export default async function ApiDocsPage() { const headersList = await headers(); const host = headersList.get("host") || "prompts.chat"; const protocol = host.includes("localhost") ? "http" : "https"; const baseUrl = `${protocol}://${host}`; return (
prompts.chat provides an MCP-first API for searching and discovering AI prompts programmatically. Use the MCP endpoint directly with any MCP-compatible client, or make standard HTTP requests.
Our API is built on the{" "} Model Context Protocol (MCP) , enabling seamless integration with AI assistants, IDEs, and automation tools. The same endpoint works for both MCP clients and traditional REST-style requests.
# MCP Endpoint
POST {baseUrl}/api/mcp
Add prompts.chat to your MCP client configuration. Choose your client and connection type below:
Remote connects directly to prompts.chat API. Local runs the MCP server locally via npx.
Most API features work without authentication. However, to save prompts via MCP or access your private prompts, you need to authenticate using an API key.
Generate an API Key
Go to{" "}
Settings
{" "}to generate your API key. Keys start with pchat_.
Using the API Key
Pass your API key via the PROMPTS_API_KEY header.
{`# Remote: HTTP transport with headers
"prompts-chat": {
"url": "${baseUrl}/api/mcp",
"headers": {
"PROMPTS_API_KEY": "pchat_your_api_key_here"
}
}
# Local: stdio transport with environment variable
"prompts-chat": {
"command": "npx",
"args": ["-y", "@fkadev/prompts.chat-mcp"],
"env": {
"PROMPTS_API_KEY": "pchat_your_api_key_here"
}
}
# Or via curl (remote)
curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "PROMPTS_API_KEY: pchat_your_api_key_here" \\
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'`}
Remote (HTTP) sends requests to prompts.chat with the API key in headers.
Local (stdio) runs the MCP server locally via npx with the API key as an environment variable.
With authentication, you can use the save_prompt tool
and search results will include your private prompts.
All public prompts are exposed as native MCP prompts. This allows MCP clients to list and use prompts directly via slash commands or prompt pickers. You can filter prompts by category or tag using URL query parameters.
{`# Filter by users (one or more usernames)
"prompts-chat": {
"url": "${baseUrl}/api/mcp?users=f,torvalds"
}
# Filter by categories
"prompts-chat": {
"url": "${baseUrl}/api/mcp?categories=coding,marketing"
}
# Filter by tags
"prompts-chat": {
"url": "${baseUrl}/api/mcp?tags=chatgpt,writing"
}
# Combine filters
"prompts-chat": {
"url": "${baseUrl}/api/mcp?users=f&categories=coding&tags=js"
}`}
prompts/list
Browse all available prompts with pagination support.
prompts/get
Retrieve a prompt by ID. Variables ({"${name}"} or {"${name:default}"}) are automatically substituted with provided arguments.
{`# List prompts
curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "Accept: application/json, text/event-stream" \\
-d '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list"}'
# Get a specific prompt with arguments
curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "Accept: application/json, text/event-stream" \\
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "prompts/get",
"params": {
"name": "code-review-assistant",
"arguments": { "topic": "AI safety" }
}
}'`}
Search for AI prompts by keyword. Returns matching prompts with title, description, content, author, category, and tags.
Get a prompt by ID. If the prompt contains template variables (like {"${variable}"} or {"${variable:default}"}), the MCP client will be asked to provide values through elicitation.
Variable Elicitation
When a prompt contains variables like {"${name}"} or {"${topic:default value}"}, MCP clients that support elicitation will prompt the user to fill in these values. Variables with default values (after the colon) are optional. The prompt content will be returned with variables replaced.
Save a new prompt to your account. Requires API key authentication. Prompts are private by default unless you've changed the default in your settings.
{`# Save a prompt via MCP
curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "PROMPTS_API_KEY: pchat_your_api_key_here" \\
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "save_prompt",
"arguments": {
"title": "My Code Review Prompt",
"content": "Review this code for \${language} best practices:\\n\\n\${code}",
"description": "A helpful code review assistant",
"tags": ["coding", "review"],
"isPrivate": false
}
}
}'`}
MCP Protocol Examples
{`curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "Accept: application/json, text/event-stream" \\
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": { "name": "my-app", "version": "1.0.0" }
}
}'`}
{`curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "Accept: application/json, text/event-stream" \\
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}'`}
{`curl -X POST ${baseUrl}/api/mcp \\
-H "Content-Type: application/json" \\
-H "Accept: application/json, text/event-stream" \\
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "search_prompts",
"arguments": {
"query": "code review",
"limit": 5
}
}
}'`}
The search_prompts tool returns results in the following format:
{`{
"query": "code review",
"count": 2,
"prompts": [
{
"id": "abc123",
"title": "Code Review Assistant",
"description": "A prompt for conducting thorough code reviews",
"content": "You are an expert code reviewer...",
"type": "TEXT",
"author": "username",
"category": "Development",
"tags": ["coding", "review", "development"],
"votes": 42,
"createdAt": "2024-01-15T10:30:00.000Z"
}
]
}`}
For simpler integrations, you can also use the standard REST endpoint:
{`# Search prompts via REST
curl "${baseUrl}/api/prompts?q=code+review&perPage=10"
# Get prompt by ID
curl "${baseUrl}/api/prompts/{id}"`}
Get MCP server information and available tools:
GET {baseUrl}/api/mcp
The API is public and free to use. Please be respectful with request frequency. For high-volume usage, consider{" "} self-hosting your own instance .
For issues and feature requests, please open a{" "} GitHub Issue .