@pikku/modelcontextprotocol
v0.11.1
Published
A Pikku MCP server runtime using the official MCP SDK
Readme
@pikku/mcp-server
A Pikku MCP server runtime that uses the official MCP SDK to expose Pikku endpoints as MCP tools.
Features
- Uses the official
@modelcontextprotocol/sdkfor MCP compliance - Automatically loads Pikku MCP endpoints from generated bootstrap files
- Configurable server name, version, and capabilities
- Supports both tools and resources
- JSON-RPC 2.0 compliant via Pikku's core MCP system
- Stdio transport for seamless integration with MCP clients
Usage
1. Generate MCP Files
First, generate the MCP JSON and bootstrap files using the Pikku CLI:
npx pikku mcpThis creates:
mcp.json- MCP tool definitions with schemasmcp-bootstrap.ts- Bootstrap file that registers all endpoints
2. Import MCP Bootstrap and Create Server
import { PikkuMCPServer } from '@pikku/mcp-server'
import { createSingletonServices } from './services'
// Import your generated MCP bootstrap to register endpoints
import './mcp-bootstrap.js'
const config = {
name: 'my-pikku-server',
version: '1.0.0',
mcpJsonPath: './mcp.json',
capabilities: { tools: {} },
// ... other CoreConfig options
}
const singletonServices = await createSingletonServices(config)
const server = new PikkuMCPServer(
config,
singletonServices,
createWireServices // optional
)
await server.init()
await server.start()3. Integration with MCP Clients
The server uses stdio transport and can be integrated with any MCP client:
{
"mcpServers": {
"pikku-server": {
"command": "node",
"args": ["./dist/server.js"]
}
}
}Configuration
The MCPServerConfig interface extends Pikku's CoreConfig with:
name: Server name for MCP identificationversion: Server versionmcpJsonPath: Path to generated MCP JSON schema filecapabilities: Optional MCP capabilities configuration
How It Works
- Bootstrap Import: User imports MCP bootstrap file to register Pikku endpoints
- Initialization: Server loads MCP JSON schema and discovers registered endpoints
- Tool Discovery:
ListToolsRequestSchemahandler returns available tools from JSON - Tool Execution:
CallToolRequestSchemahandler routes requests to Pikku's MCP system - Response Formatting: Converts Pikku responses to MCP format
Example MCP Tool Response
{
"content": [
{
"type": "text",
"text": "{\"userId\": \"123\", \"name\": \"John Doe\"}"
}
]
}