@jaypie/mcp
Prerequisites: npm install @jaypie/mcp
Status: Experimental - APIs may change
Overview
Section titled âOverviewâ@jaypie/mcp provides utilities for building MCP (Model Context Protocol) servers that expose Jaypie service handlers as tools for AI assistants.
Installation
Section titled âInstallationânpm install @jaypie/mcpQuick Reference
Section titled âQuick ReferenceâExports
Section titled âExportsâ| Export | Purpose |
|---|---|
registerMcpTool |
Register service handler as MCP tool |
createMcpServer |
Create MCP server instance |
MCP Tool Registration
Section titled âMCP Tool RegistrationâBasic Registration
Section titled âBasic Registrationâimport { registerMcpTool } from "@jaypie/mcp";import { fabricService } from "@jaypie/fabric";
const getUserHandler = fabricService({ alias: "get_user", description: "Get user by ID", input: { userId: { type: String }, }, service: async ({ userId }) => { const user = await db.users.findById(userId); return user; },});
registerMcpTool(server, getUserHandler);With Callbacks
Section titled âWith CallbacksâregisterMcpTool(server, handler, { onMessage: (message) => { console.log("Progress:", message); }, onComplete: (result) => { console.log("Complete:", result); }, onError: (error) => { console.error("Error:", error); },});Service Handler to MCP Tool
Section titled âService Handler to MCP ToolâService handlers automatically convert to MCP tools:
| Fabric Type | JSON Schema Type |
|---|---|
string |
string |
number |
number |
boolean |
boolean |
array |
array |
object |
object |
date |
string (format: date-time) |
uuid |
string (format: uuid) |
Creating MCP Server
Section titled âCreating MCP Serverâimport { createMcpServer, registerMcpTool } from "@jaypie/mcp";import { handlers } from "./handlers.js";
const server = createMcpServer({ name: "my-service", version: "1.0.0",});
// Register all handlersfor (const handler of handlers) { registerMcpTool(server, handler);}
// Start serverserver.listen();Response Format
Section titled âResponse FormatâMCP tools return responses as text content:
// Handler returns:{ name: "Alice", email: "alice@example.com" }
// MCP response:{ content: [ { type: "text", text: '{"name":"Alice","email":"alice@example.com"}' } ]}Error Handling
Section titled âError HandlingâJaypie errors are converted to MCP error responses:
const handler = serviceHandler({ name: "get_user", handler: async ({ userId }) => { const user = await db.users.findById(userId); if (!user) { throw NotFoundError("User not found"); } return user; },});
// MCP receives error with status and messageInput Validation
Section titled âInput ValidationâInput validation from fabric is enforced:
const handler = fabricService({ input: { email: { type: String, validate: (value) => value.includes("@"), }, }, service: async ({ email }) => { // email is guaranteed valid },});Prompts and Resources
Section titled âPrompts and ResourcesâList Prompts
Section titled âList Promptsâimport { mcp__jaypie__list_prompts } from "@jaypie/mcp";
const prompts = await mcp__jaypie__list_prompts();// Returns available Jaypie development promptsRead Prompt
Section titled âRead Promptâimport { mcp__jaypie__read_prompt } from "@jaypie/mcp";
const content = await mcp__jaypie__read_prompt({ filename: "Development_Process.md",});Datadog Integration
Section titled âDatadog IntegrationâBuilt-in tools for Datadog monitoring:
import { mcp__jaypie__datadog_logs, mcp__jaypie__datadog_monitors, mcp__jaypie__datadog_synthetics,} from "@jaypie/mcp";
// Query logsconst logs = await mcp__jaypie__datadog_logs({ query: "status:error", from: "now-1h",});
// Check monitorsconst monitors = await mcp__jaypie__datadog_monitors({ status: ["Alert", "Warn"],});LLM Debug Tools
Section titled âLLM Debug ToolsâDebug LLM API calls:
import { mcp__jaypie__llm_debug_call } from "@jaypie/mcp";
const response = await mcp__jaypie__llm_debug_call({ provider: "anthropic", message: "Test message", model: "claude-sonnet-4",});Configuration
Section titled âConfigurationâEnvironment variables:
| Variable | Purpose |
|---|---|
DD_API_KEY |
Datadog API key |
DD_APP_KEY |
Datadog app key |
DD_ENV |
Default environment filter |
DD_SERVICE |
Default service filter |
Related
Section titled âRelatedâ- Fabric - Service handler patterns
- LLM Integration - LLM tools
- @jaypie/llm - LLM package