Agent / foldkit-agent-mcp

Sixty seconds: serve a bound runtime

Start with the Agent contract and host guide. The integration below assumes AssistantAgent is your declared contract and AgentBuilder is its application-specialized builder. agentRuntime is the result of binding that contract to your live host and verified principal.

The smallest MCP server is stdio:

ts
import { AgentMcp } from 'foldkit-agent-mcp'

const server = AgentMcp.stdio({ agent: agentRuntime })

stdio attaches to the process streams immediately. Retain the returned handle and call server.close() on application shutdown. Keep application logs on stderr so stdout remains the MCP protocol stream.

That gives an MCP client the capabilities/resources derived from the same contract used by every other adapter.

For embedding or tests, the protocol mapping is also exposed without a transport:

ts
const served = AgentMcp.handler({
  agent: agentRuntime,
  onNotification: send,
})

await served.handle({
  jsonrpc: '2.0',
  id: 1,
  method: 'tools/list',
})

What the contract becomes

MCPfoldkit-agent
tools/listcapabilities currently available in the Model
tools/callAgentRuntime dispatch by protocol name
resources/list / resources/readnamed resources plus app://context
notifications/tools/list_changedadvertised capability set changed
notifications/cancelledabort the matching invocation

The adapter derives input schemas from the capability's Effect Schema. A capability with a completion contract resolves after its correlated success or failure Message; otherwise validated dispatch is the completion boundary.