Skip to content

feat(pi-mono): add @keycardai/pi-mono package#9

Open
Larry-Osakwe wants to merge 4 commits into
mainfrom
larry/pi-mono-integration
Open

feat(pi-mono): add @keycardai/pi-mono package#9
Larry-Osakwe wants to merge 4 commits into
mainfrom
larry/pi-mono-integration

Conversation

@Larry-Osakwe
Copy link
Copy Markdown
Collaborator

Summary

  • Adds @keycardai/pi-mono — a new package that enables pi-mono coding agents to use Keycard-protected MCP servers
  • Converts MCP tools to pi-mono's AgentTool format with OAuth auth detection and auth-aware system prompts
  • Follows the same integration pattern as the Python SDK's OpenAI/CrewAI/LangChain adapters

What's included

File Purpose
packages/pi-mono/src/client.ts PiMonoClient — main adapter (detect auth status, convert tools, generate prompts)
packages/pi-mono/src/tools.ts MCP Tool → AgentTool conversion via Type.Unsafe() for JSON Schema → TypeBox bridging
packages/pi-mono/src/auth-tools.ts Pluggable AuthToolHandler interface + Default/Console implementations
packages/pi-mono/src/prompt.ts Auth-aware system prompt section generator
packages/pi-mono/src/types.ts Shared type definitions
packages/sdk/src/pi-mono.ts Re-export via @keycardai/sdk/pi-mono subpath

How it works

Pi-mono agents pass tools as AgentTool[] to createAgentSession(). This package:

  1. Takes connected MCP Client instances (user sets up transports + auth)
  2. Detects auth status by probing each server
  3. Converts authorized servers' MCP tools → pi-mono AgentTool instances
  4. Generates a request_authorization tool for unauthorized servers
  5. Builds an auth-aware system prompt section

All pi-mono framework features (extensions, skills, AGENTS.md discovery, session management, compaction, thinking levels) work unchanged — our tools are just additional entries in the agent's toolkit.

README updates

Added a "Which Package?" table to the root README guiding users to the right package for their use case.

Test plan

  • TypeScript typecheck passes (pnpm -r run typecheck)
  • Full monorepo build passes (pnpm -r run build)
  • 44 unit tests: tool conversion, auth handlers, prompt generation, client lifecycle
  • 121 total tests across monorepo (no regressions: oauth 16, mcp 61, pi-mono 44)
  • E2E test (direct): local MCP server + InMemoryTransport + PiMonoClient → tool execution verified
  • E2E test (full): pi-mono createAgentSession() with Anthropic API key → LLM successfully called MCP tool through AgentTool wrapper

🤖 Generated with Claude Code

Larry-Osakwe and others added 4 commits April 6, 2026 10:50
…ration

Adds a new package that enables pi-mono coding agents to use
Keycard-protected MCP servers. Converts MCP tools to pi-mono's
AgentTool format, handles OAuth auth detection, and generates
auth-aware system prompts.

- PiMonoClient: main adapter (detect auth, get tools, system prompt)
- Tool conversion: MCP Tool → AgentTool via Type.Unsafe() for schema bridging
- Auth tools: pluggable AuthToolHandler with Default/Console implementations
- Prompt builder: auth-aware system prompt section generator
- Unit tests: 44 tests covering tools, auth, prompt, client
- E2E test: local MCP server + InMemoryTransport + pi-mono agent session
- SDK re-export via @keycardai/sdk/pi-mono subpath
- README: "Which Package?" table for user guidance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove getErrorServers() — "error" status was never set by detectAuthStatus()
- Remove "error" from ServerAuthStatus union — no code path produces it
- Remove unused AgentToolUpdateCallback re-export from types.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Runnable pi-mono agent with Keycard MCP tools — connects to
Keycard-protected servers, converts tools, streams responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant