Skip to content

Added capa sh - #18

Merged
Minitour merged 3 commits into
mainfrom
develop
Mar 4, 2026
Merged

Minitour merged 3 commits into
mainfrom
develop

Conversation

@Minitour

@Minitour Minitour commented Mar 4, 2026

Copy link
Copy Markdown
Member

capa sh — CLI Tool Executor

Summary

Introduces capa sh, a non-interactive command-line tool runner that exposes every configured MCP and command tool as a first-class CLI command. Designed to work equally well for humans and AI agents.

Also includes server-side improvements to MCP result serialization and new optional metadata fields (description, group) on servers and tools.


What's new

capa sh command (src/cli/commands/sh.ts, src/cli/index.ts)

  • capa sh lists all available commands grouped by MCP server or command tool group.
  • capa sh <group> lists subcommands within that group.
  • capa sh <group> <subcommand> [--arg value ...] executes a tool and prints the result, then exits.
  • capa sh <unknown> passes the command through to the OS shell.
  • Contextual --help / -h / help at every level (top-level, group, subcommand).
  • All tool IDs are slugified to kebab-case (list_merge_requests → list-merge-requests).
  • Fully non-interactive — every invocation runs one command and exits, making it safe for AI agent use (no readline, no REPL).
  • All tools are visible regardless of expose-all / on-demand mode.

Tool metadata fields (src/types/capabilities.ts)

  • description?: string added to both MCPServer and Tool. Displayed in capa sh output; falls back to a generic label when absent.
  • group?: string added to Tool. Command tools sharing a group are nested under a parent command in capa sh. A group with only one member is promoted to the top level.

Shell tools API endpoint (src/server/index.ts)

  • New GET /api/projects/:id/shell-tools endpoint returns every tool with its full input schema, server/group metadata, and descriptions — regardless of exposure mode. Used by capa sh at invocation time.

MCP result serialization fix (src/server/mcp-handler.ts)

  • New serializeToolResult method detects double-encoded MCP proxy results (arrays of { type, text } content items where text is itself a JSON string) and unwraps them: parses the inner JSON, returns a single object if there is only one item, or a JSON array otherwise. Applies to all four tool call response paths.
  • Exports ShellToolInfo interface and getAllShellTools method for use by the shell tools endpoint.

Minitour added 3 commits March 4, 2026 01:40
Added capa sh which allows the conversion of any MCP into a CLI tool
@Minitour
Minitour merged commit eb40bc7 into main Mar 4, 2026
8 checks passed
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