Skip to main content
Wire Type: MCP

AI tools,
same functions.

Add mcp: true to any Pikku function and it becomes an MCP tool. Resources and prompts use dedicated function types — all exposed automatically via the Model Context Protocol.

Three Primitives

Tools, resources, prompts

MCP defines three primitives for AI integration. Pikku exposes your functions automatically — no wiring code needed.

Tools

Any Pikku function becomes a tool — just add mcp: true.
todo.functions.tsmcp: true
// Any Pikku function becomes an MCP tool with mcp: true
export const createTodo = pikkuFunc({
description: 'Create a new todo item',
input: CreateTodoInput,
output: CreateTodoOutput,
mcp: true, // ← That's it. Now it's an MCP tool.
func: async ({ db }, { text, priority }) => {
return await db.createTodo({ text, priority })
},
})

Resources

Data the AI can read. URI templates with typed parameters.
mcp.functions.tspikkuMCPResourceFunc
// MCP resources use a dedicated function type
export const getTodo = pikkuMCPResourceFunc({
uri: 'todos/{id}',
title: 'Todo Details',
description: 'Get a todo by ID',
func: async ({ db }, { id }, { mcp }) => {
const todo = await db.getTodo(id)
return [{ uri: mcp.uri!, text: JSON.stringify(todo) }]
},
})

Prompts

Prompt templates the AI can use. Return structured message arrays.
mcp.functions.tspikkuMCPPromptFunc
// MCP prompts use a dedicated function type
export const codeReview = pikkuMCPPromptFunc({
name: 'codeReview',
description: 'Generate a code review prompt',
func: async ({}, { filePath, context }) => {
return [{
role: 'user',
content: {
type: 'text',
text: `Review ${filePath}. Context: ${context}`
}
}]
},
})

Wire Object

Dynamic control at runtime

Every MCP function gets a wire.mcp object to notify resource changes and toggle capabilities.

sendResourceUpdated(uri)

Notify the AI that a resource changed — it can re-read it to get fresh data.

enableTools / enableResources / enablePrompts

Dynamically show or hide capabilities based on context. Pass a map of names to booleans.

mcp.functions.ts
export const manageTodos = pikkuFunc({
description: 'Manage todo items',
input: ManageTodosInput,
output: ManageTodosOutput,
mcp: true,
func: async ({ db }, { action, id }, { mcp }) => {
if (action === 'delete') {
await db.deleteTodo(id)

// Notify AI that the resource changed
mcp.sendResourceUpdated(`todos/${id}`)

// Dynamically enable/disable tools
await mcp.enableTools({ archiveTodos: true })

return { deleted: true }
}
// ...
},
})

Start wiring MCP in 5 minutes

One command to scaffold a project with MCP wiring already configured.

$ npm create pikku@latest

MIT Licensed  ·  Tools, Resources & Prompts