Skip to content

MCP Integration ​

iKi supports the Model Context Protocol (MCP) over both local stdio and remote HTTP/SSE transports, allowing the agent to work directly with external systems such as Zotero, GitHub, databases, or internal APIs.

Walkthrough: Connecting Zotero MCP ​

Real-world MCP servers often expose dozens of tools. For example, zotero-mcp (installed via uv tool install zotero-mcp) exposes 35 tools covering library search, PDF outlines, annotations, notes, collections, and BibTeX export.

1. Install and Register the Server ​

Once zotero-mcp is installed on your PATH, register it inside iKi:

bash
/mcp add zotero zotero-mcp serve

If you already maintain a mcp.json for Claude Code or Cursor (.mcp.json, .iki/mcp.json, or ~/.iki/mcp.json), import it directly instead:

bash
/mcp import

Remote HTTP/SSE servers can be added with /mcp add-http <name> <url>.

2. Why Code Mode Matters on a 35-Tool Server ​

The raw JSON Schema for zotero-mcp's 35 tools is 29,125 characters (~7,300 tokens). In traditional MCP integrations, that entire schema array is sent as top-level tools on every single turn—and disconnecting or reconnecting a server alters the tool list and invalidates the provider's prompt cache.

iKi defaults to Code Mode (exposureMode = "code"):

  • The top-level tool list sent to the model stays fixed (bash/pwsh, job, ptc).
  • When zotero connects, iKi sends a compact summary (~360 characters) once in the conversation rather than 29 KB of raw JSON Schema.
  • When the model needs exact parameter types for specific Zotero tools, it queries generated TypeScript declarations on demand (also inspectable interactively via /mcp dts zotero) and executes calls through the TypeScript Code Sandbox.

For example, /mcp dts zotero zotero_search_items produces:

typescript
declare namespace mcp.zotero {
  /** Keyword search of item metadata: substring match on title, creators and year */
  function zotero_search_items(args: {
    query?: string;
    qmode?: "titleCreatorYear" | "everything";
    item_type?: string;
    limit?: number;
    tag?: string[];
    collection_key?: string;
    include_subcollections?: boolean;
    search_all_libraries?: boolean;
  }): Promise<McpResult>;
}

With Zotero connected, a single request such as "Find papers on KV-Cache in Zotero, gather their PDF annotations, and export BibTeX citations" can search the library (zotero_search_items), fetch annotations across all matched papers in parallel (zotero_get_annotations), and export citations (zotero_export_bibliography) in one turn.

Code Mode vs. Direct Mode ​

MCP integration and the code sandbox are separate concerns—if you prefer registering every MCP tool directly as a top-level model tool, switch modes at any time:

bash
/mcp mode direct   # expose MCP tools directly as top-level tools
/mcp mode code     # expose MCP tools via Code Mode (default)

Configuration ​

Configure MCP defaults in ~/.iki/settings.toml:

toml
[mcp]
enabled = true
exposureMode = "code"      # "code" (default) | "direct"
connectOnStartup = true
requestTimeoutMs = 20000
maxConcurrentRequests = 4

Released under AGPL-3.0-only.