README
¶
skill-cli
A Go CLI for AI agents and scripts to discover, inspect, and invoke MCP tools and HTTP APIs without placing an entire tool catalog in model context. The executable and project name are skill-cli.
Read the standalone visual expert guide for command examples, architecture diagrams, MCP/OpenAPI adapters, OAuth and error recovery. Download and open the HTML file in a browser; it works offline.
Working alpha. Supports MCP over stdio, Streamable HTTP and legacy SSE; OpenAPI 3.0.x/3.1.x and normalized Swagger 2.0 JSON/YAML; and direct HTTP requests with query parameters, headers, and JSON bodies. An optional authenticated loopback gateway retains MCP connections and resolves provider credentials outside the calling CLI. Discovery stays small; operation schemas are requested separately. Skillhub comparison and merge decisions.
Named credentials now support the OS keyring, environment variables and existing secret-manager commands. Agents can validate calls with --dry-run and request explicitly marked partial discovery with search --best-effort. See the credential guide and prioritized agent-calling research.
The next batch adds connection-free provider search, bounded parallel discovery, optional gateway catalog caching and validated plans with fresh contract guards. See discovery and plans and the controlled measurements.
Explicit MCP OAuth login now supports discovery, PKCE, a loopback callback, OS keyring sessions, pre-request refresh, pre-registered confidential clients, explicit device consent and token revocation. Try the public-service walkthrough or the actionable demo error. Use --pretty for readable JSON and list --tools to enumerate operations across providers.
中文完整操作手册(Bash / PowerShell 双版本):usage.zh-CN.md。
按需插件目录与版本管理技术方案:Markdown · 离线 HTML 架构与交互图。客户端已支持远端 /api/v1/skills 三接口;网关服务需按契约另行部署。使用 catalog use URL --credential NAME 保存默认目录,或显式传 --catalog URL --catalog-credential NAME。
Configuration distribution and maintenance
skill-cli config use ./plugins.json
skill-cli config use https://plugins.example.com/catalog/v1/config.json
skill-cli config sync https://plugins.example.com/catalog/v1/config.json --out plugins.json
skill-cli import wiki -type=mcp --url https://mcp.deepwiki.com/mcp --out plugins.json
skill-cli import api -type=openapi --spec ./openapi.yaml --url https://api.example.com --out plugins.json
skill-cli proxy set http://127.0.0.1:7890
skill-cli version
skill-cli upgrade --check
Example domains are deployment templates. Configuration selection is explicit --config, then saved config_source, then the current skill-cli.json. Remote configuration accepts HTTPS without query/credentials, resolves relative spec URLs, and rejects local executable/skill-file references. config sync publishes a normalized local snapshot atomically; optional --sha256 checks that normalized snapshot. Remote specs can be reimported with --replace. Configuration and provider authentication are separate; private configuration downloads are not yet authenticated.
Use skill-cli upgrade, skill-cli upgrade 0.2.0, or the update alias. The updater pins wolvever/skill-cli stable GitHub Releases, verifies checksums and OS/architecture, probes the candidate's version, and retains a backup with post-install rollback. Versioned Go installs and detected package-manager paths return their original upgrade instructions instead of being overwritten. --check reports availability without replacing the executable. See the upgrade usage guide.
The tag workflow builds six platform binaries and checksums.txt, validates executable formats and native startup, then creates a draft Release for verification before publication. Stable published Releases feed upgrade; drafts and prereleases do not. See the binary installation and upgrade guide for Bash and PowerShell instructions. SHA-256 checksums are not publisher signatures; OS code signing is not provided. Explicit proxy settings cover ordinary network clients and updates; OAuth retains its direct, DNS-checked path.
Try it locally
Simple calls accept key=value in both Bash and PowerShell:
skill-cli call legacy.add a=2 b=3
skill-cli call issues.searchIssues query=login limit=2
skill-cli call pets.getPet --string id=42 verbose=true
skill-cli plan demo.add a=2 b=3
Use your provider config with --config FILE (default skill-cli.json). Valid JSON values infer their types; other text stays a string. Use repeatable --string key=value for literal strings such as numeric IDs. Shell quotes alone do not force the value's type. Duplicate fields and mixing assignments with --args are rejected. Complex objects can still use --args @args.json or stdin; no schema fetch is added by this shorthand.
Requires Go 1.25 or newer to build. The resulting executable needs no Go, Node, or Python runtime. A configured stdio server may require its own runtime.
git clone https://github.com/wolvever/skill-cli.git
cd skill-cli
go build -o bin/skill-cli ./cmd/skill-cli
go run ./examples/demo-server --listen 127.0.0.1:8080
In another terminal:
bin/skill-cli --config examples/demo.json list
bin/skill-cli --config examples/demo.json list demo
bin/skill-cli --config examples/demo.json search add
bin/skill-cli --config examples/demo.json search search --limit 5
bin/skill-cli --config examples/demo.json describe demo.add
bin/skill-cli --config examples/demo.json call demo.add --args '{"a":2,"b":3}'
bin/skill-cli --config examples/demo.json call legacy.add --args '{"a":2,"b":3}'
bin/skill-cli --config examples/demo.json call pets.getPet --args '{"id":"42","verbose":true}'
bin/skill-cli --config examples/demo.json request rest GET /pets/42
On Windows, build bin/skill-cli.exe and invoke ./bin/skill-cli.exe. JSON files avoid differences in shell quoting:
skill-cli call demo.echo --args @args.json
cat args.json | skill-cli call demo.echo --args -
In PowerShell, pipe with Get-Content -Raw args.json. No demo operation changes external state or needs credentials. examples/skill-cli.json shows real-service configuration patterns and requires adapting the local server path and credentials.
For a complete PowerShell example, start the server above, then run in a second terminal:
go build -o bin/skill-cli.exe ./cmd/skill-cli
$cli = ".\bin\skill-cli.exe"
$cfg = "examples/demo.json"
& $cli --config $cfg search search --limit 5
& $cli --config $cfg describe demo.search_issues
'{"query":"login","limit":2}' | & $cli --config $cfg call demo.search_issues --args -
'{"query":"login","limit":2}' | & $cli --config $cfg call issues.searchIssues --args -
The last two commands return the same issue-search data through MCP and OpenAPI. This fixture was adapted from the earlier Skillhub evaluation into a portable Go demo and regression tests.
Agent interface
| Command | Contract |
|---|---|
list |
Provider names, protocols and configured descriptions; does not connect |
list <provider> [--limit N] [--full] |
Operation IDs and short descriptions, without schemas |
list --tools [--limit N] [--best-effort] |
Discover operations across all providers, optionally returning completeness/failures |
search <text> [--provider name] [--limit N] |
Local BM25 ranking; top 10 short candidates, no schemas |
search <text> --providers |
Rank configured provider/skill summaries without connections |
describe <provider.operation> |
One input schema and available output schema/annotations |
plan <provider.operation> --args @file |
Validate arguments and return a fresh full contract plus digest; do not invoke |
call <provider.operation> --args JSON|@file|- |
Invoke once with a JSON object |
call <provider.operation> --args @file --dry-run |
Validate arguments using metadata; do not invoke the operation |
call <provider.operation> --args @file --expect-contract HASH |
Require a matching fresh contract/config digest and valid arguments, then invoke once |
request <provider> <method> </path> |
HTTP request with optional --query, --header, --body |
serve |
Persistent gateway for one trusted configuration and principal |
auth set <name> --stdin|--from-env NAME [--replace] |
Store/rotate one named OS keyring item; never print its value |
auth status [name] [--check] |
Check source readiness; command sources run only with --check |
auth delete <name> |
Delete one local OS item; does not revoke the upstream token |
auth discover <provider> |
Inspect public OAuth metadata without registration or login |
auth login <provider> [--browser] [--device] |
Explicit PKCE or advertised device consent; store successful tokens in OS keyring |
auth status [provider] --oauth |
Read local OAuth state without refreshing or contacting the provider |
auth logout <provider> [--revoke] |
Delete local OAuth session; --revoke first requests refresh/access token revocation |
Operational stdout is exactly one JSON envelope. Global --pretty indents it; compact output remains the default. Help/version are plain text; OAuth login URLs go to stderr. Both protocol errors and MCP isError results exit 1, preserving tool-error data when available:
{"ok":true,"data":{"structuredContent":{"sum":5}}}
The exact MCP result may also contain content blocks and protocol metadata. HTTP results contain status, contentType, and body. Errors keep a readable error string and add stable code and recovery hint fields, optionally with upstream data:
{"ok":false,"error":"HTTP 429","code":"RATE_LIMITED","hint":"Respect the provider's rate limit before making another request."}
Codes distinguish INVALID_ARGUMENT, CONFIG_ERROR, NOT_FOUND, AUTH_FAILED, PERMISSION_DENIED, RATE_LIMITED, PROVIDER_UNAVAILABLE, TIMEOUT, CANCELLED, TOOL_ERROR, and other UPSTREAM_ERROR failures. RESPONSE_TOO_LARGE asks for a smaller response or a larger explicit limit. Unknown MCP protocol errors remain upstream errors rather than being classified by guessing at their message text. Machine-readable failures stay on stdout so existing consumers can parse one envelope; incidental server diagnostics go to stderr. MCP content is preserved rather than guessing whether a text block should be decoded as JSON.
Search ranks operation names, descriptions, argument names and configured provider/skill metadata using local BM25, with identifier splitting and a typo fallback when no lexical terms match. Chinese retrieval adds bounded Han bigrams with conservative overlap checks. Trusted local search_aliases supports directional, one-pass terminology expansion (for example, "工单": ["issue"]); it does not translate queries automatically or change invocation authority. It needs no model download, API key, database or service. Exact IDs take priority; semantic reasoning and reliable negation handling still require the agent. Search returns at most 10 candidates by default; --limit 0 returns all matches. List/search descriptions are bounded to 180 runes; --full restores complete descriptions and annotations, while describe returns the complete available schema and instructions. Limits reduce output, not upstream tools/list work. Legacy matching remains available with --match substring --limit 0 --full. Read the retrieval design and alternatives.
Use -- before option-like positional values. Provider names allow letters, digits, underscores, and hyphens. Operation names are preserved literally after the first dot: docs.search.issues-v2 addresses provider docs, operation search.issues-v2, without normalization or alias collisions.
By default, an unavailable provider fails a cross-provider search. search TEXT --best-effort instead returns data.items, data.complete and data.failures (provider/code/hint), so healthy providers can still be used. This opt-in mode changes the search data shape from an array to an object. If all selected providers fail, the command exits nonzero and preserves failure details. An incomplete search cannot establish that an operation is unavailable.
call ID --args @args.json --dry-run validates MCP arguments against the discovered schema or OpenAPI arguments through the existing mapper. It returns {"id":"provider.operation","valid":true,"invoked":false} on success. It may initialize/start an MCP server or fetch metadata/specs; it sends no tools/call or API operation. Local MCP validation supports draft-07 and 2020-12, rejects external schema fetches and preserves numeric inputs. Schema validation does not prove business correctness, credential scope or authorization. Normal calls still invoke once, without an implicit validation/discovery round trip.
plan ID --args @args.json combines fresh inspection and argument validation, returning target, args, full contract, contractHash, valid:true and invoked:false. Use its digest with call ... --expect-contract HASH to detect changed schemas, descriptions or configured destinations before sending the operation. CONTRACT_CHANGED stops the call. Plans/guards reload OpenAPI sources; the guard does not freeze remote state, authorize an action or replace upstream validation. See the full PowerShell example and limits.
--timeout 30s covers connection setup and invocation. --max-bytes 16777216 bounds CLI input/output, HTTP response bodies, spec files, gateway payloads, and individual MCP HTTP SSE events. It is not a pre-allocation memory limit for SDK-decoded MCP stdio results or a limit on the number of discovered schemas. A timeout can leave an unknown execution outcome. Calls and multi-round continuations are never automatically replayed.
Providers and credentials
{
"providers": {
"docs": {"type":"mcp","transport":"http","url":"https://example.com/mcp","headers":{"Authorization":"Bearer ${DOCS_TOKEN}"},"allow":["search"]},
"local": {"type":"mcp","transport":"stdio","command":["python","/absolute/server.py"],"env":{"API_KEY":"${LOCAL_API_KEY}"}},
"api": {"type":"openapi","spec":"./api.yaml","url":"https://api.example.com","headers":{"X-API-Key":"${API_KEY}"}},
"rest": {"type":"http","url":"https://api.example.com","headers":{"Authorization":"Bearer ${API_TOKEN}"}}
}
}
Spec file paths resolve relative to the configuration file. Stdio arguments are an executable plus an argument array, without an implicit shell. Working directory is the process working directory. The env map sets child environment values using literal text or templates; other process environment variables are inherited. Use executable programs such as node or python on Windows; invoke batch scripts explicitly through a shell only when needed.
Use headers for HTTP requests and env for stdio processes. Values accept literals, ${VARIABLE}, ${VARIABLE:-default}, and ${keyring:name}. Missing required values fail before invocation; templates never execute shell commands. For example, skill-cli auth set github --from-env GITHUB_TOKEN stores a token, then "headers":{"Authorization":"Bearer ${keyring:github}"} uses it without a credentials table. Keyring uses Windows Credential Manager, macOS Keychain, or Linux/BSD Secret Service, with no plaintext fallback. Remote catalogs cannot bind host secrets, including after synchronization.
For an existing secret manager, named sources can be bound explicitly:
{
"credentials": {
"github-work": {"source":"keyring"},
"ci": {"source":"env","env":"SERVICE_TOKEN"}
},
"providers": {
"github": {"type":"http","url":"https://api.github.com","bearer_credential":"github-work"},
"docs": {"type":"mcp","transport":"http","url":"https://mcp.example.com/mcp","header_credentials":{"X-API-Key":"ci"}}
}
}
With a token already in the trusted host's GITHUB_TOKEN environment variable, run skill-cli auth set github-work --from-env GITHUB_TOKEN. Use auth status github-work --check, then request github GET /user with your config. Use --stdin to pipe from an existing secret manager, and --replace for intentional rotation. Values are never printed by management commands; no plaintext storage fallback is used. See credential management and example configuration for command sources, stdio bindings, platform requirements and isolation limits.
Secrets are resolved on each new HTTP request. Remote spec downloads are unauthenticated; download authenticated specs separately. Redirects and cross-origin credential forwarding are refused. Managed bearer/header bindings require an explicit HTTPS provider URL, with an HTTP loopback-IP exception for local fixtures. An upstream provider or stdio server may echo/log what it receives; arbitrary response bodies are not automatically redacted.
An optional nonempty allow list hides and denies every operation not listed, including gateway calls. Omitting it (or setting an empty list) permits all operations. Raw HTTP requests are disabled for providers with an operation allowlist so they cannot bypass it. Configure a provider URL explicitly when the API spec should not select the destination. Treat configs, specs, and stdio executables as trusted operator input.
Configuration rejects unknown fields and extra JSON values, so a misspelled policy field cannot silently disappear. One-shot commands do not write home-directory discovery or usage caches.
Providers may add description, keywords, skill_descriptions and skill_files for discovery. Skill paths resolve relative to the config and accept a SKILL.md file or folder. Only the explicitly configured frontmatter name and description are indexed, bounded to 64 KiB; skill bodies/scripts are not indexed or executed. Provider summaries appear in list without opening server connections. Keep broad metadata concise because it applies to every allowed tool from that provider.
Try the public catalog (10 MCP servers and two OpenAPI sources):
skill-cli --config benchmarks/public.json list
skill-cli --config benchmarks/public.json search "framework documentation" --providers --limit 3
skill-cli --config benchmarks/public.json search "Svelte component fixes" --provider svelte --limit 3
skill-cli --config benchmarks/public.json list nuxt --limit 5
skill-cli --config benchmarks/public.json describe svelte.svelte-autofixer
These discovery commands contact public servers when listing tools or searching. Public availability and anonymous quotas can change. Narrow searches by provider to reduce network work and isolate failures.
HTTP requests
Use a configured provider, a method, and a relative path. The local demo supports:
skill-cli --config examples/demo.json request rest GET /issues --query query=login --query limit=2
skill-cli --config examples/demo.json request rest POST /echo --query tag=one --query tag=two --header X-Mode=safe --body @body.json
--query key=value can repeat, including the same key, and values are URL-encoded. Existing path queries are retained. --header Name=value supplies non-credential API options. Routing/framing headers and Authorization, Proxy-Authorization, and Cookie overrides are rejected; use environment bindings for secrets. There is no per-request arbitrary upstream override.
--body accepts any single JSON value, @file, or - for stdin, including arrays, booleans, strings, and explicit null. Large integer literals are preserved. The earlier --args form remains supported for object bodies, but cannot be combined with --body. OpenAPI call still takes an argument object; its body member can be any JSON value permitted by that operation's schema.
Persistent gateway
Start one gateway per principal/security context. In the trusted host environment, set provider credentials and a random SKILL_CLI_GATEWAY_TOKEN of at least 24 characters, then:
skill-cli --config skill-cli.json serve --listen 127.0.0.1:7331
The calling environment needs the gateway URL and gateway token:
skill-cli --gateway http://127.0.0.1:7331 list
skill-cli --gateway http://127.0.0.1:7331 call docs.search --args @args.json
No local provider config is read in gateway mode. The foreground service lazily opens one MCP session per configured provider and retains it until shutdown. Discovery defaults to four providers concurrently, with a ten-second per-provider metadata deadline inside the overall request deadline. Configure the runtime host with --discovery-concurrency 1..32 and --provider-timeout DURATION; 1 and 0 restore sequential/overall-deadline discovery. Metadata results remain deterministic. Persistent HTTP/SSE session lifetime is independent of the first discovery request.
Tool catalogs are live by default. Opt into in-memory public catalog reuse on the gateway host with --catalog-ttl 30s; --catalog-max-bytes defaults to a 16 MiB serialized cache budget, not a peak RSS limit. Credential-bound/OAuth/stdio catalogs remain live. TTL expiry, received MCP tool-list changes and explicit --refresh invalidate metadata; failed refreshes do not retain their old entry. No disk cache is written. OpenAPI sources reload on refresh, enabled-cache expiry, plans and guarded calls. Restart to load provider config/account changes or recover a broken session; automatic reconnect, idle eviction and multiple principals remain unimplemented. OAuth refresh happens before new HTTP requests on the trusted host; already-open streams retain their initial authentication.
Provider credentials may come from the gateway host's OS keyring, environment or configured secret-manager command. HTTP requests pick up source rotation; open streams and stdio process environments need a session restart to reauthenticate. Credential-management commands are local-only and cannot be called through --gateway. OS storage alone does not isolate secrets from another process with the same OS-user privileges.
The gateway binds only to loopback, validates Host, rejects browser Origins, limits request sizes/deadlines, and authenticates every invocation. It does not itself create sandbox network isolation. Reaching a gateway in another container requires an operator-managed authenticated/TLS bridge; do not expose loopback through an unauthenticated port forward. The gateway token grants the configured capability set and is itself sensitive. This is a building block, not a production multitenant credential vault, policy engine, or sandbox escape boundary.
OpenAPI support and current limits
OpenAPI 3.0.x/3.1.x and normalized Swagger 2.0 JSON/YAML support operation IDs (fallback: get:/path), JSON bodies, internal references, and explicit credential bindings. OpenAPI 3.1 validation uses kin-openapi's JSON Schema 2020-12 mode, including const, union types, prefixItems, boolean schemas and $ref siblings. Query form handles scalar arrays and flat objects; deepObject handles flat objects with explode=true. Query spaceDelimited/pipeDelimited handle scalar arrays with explode=false; structural separators are added after component escaping. Path/header simple handles scalars, scalar arrays and flat objects. Query/path components are escaped individually, preserving literal commas and slashes. Multipart bodies accept inline scalar fields or arrays of scalars from the body JSON object, with a total encoded size limit; they never read local files. See the Chinese manual for examples.
Swagger 2.0 uses the same import NAME -type=openapi command. See examples/swagger2.yaml. Array collectionFormat supports csv (including omitted default), multi, ssv and pipes for query parameters; non-query arrays use csv. Internal definitions/parameter references and JSON bodies are normalized using the existing kin-openapi converter. Security definitions do not acquire credentials or trigger OAuth.
Unsupported forms fail before the HTTP call: Swagger formData and unsupported collectionFormat (including tsv), OpenAPI 3.2+, external references, cookie parameters, allowReserved, parameter content, matrix/label styles, nested URL/header arrays or objects, multipart binary files and multipart encoding overrides. Path/operation server overrides are also unsupported. securitySchemes do not automatically authenticate; use explicit credential bindings. Distinct exploded query parameters cannot collide on a key. Header component commas/equals are rejected because there is no standard header percent-decoding step. describe bundles transitively referenced schemas and includes multipart input.
GraphQL, gRPC, general JSON-RPC, semantic search, SDK/CLI generation, result storage, async tasks, prompts/resources/subscriptions, cross-principal session pools, audit logging, rate limits, and approval policies remain roadmap items. Initial OAuth login/refresh supports remote MCP with published metadata and public-client registration options; explicit device grants, operator-supplied confidential clients and token revocation are supported; enterprise extensions remain unsupported. See OAuth scope and validation; this is not full MCP authorization conformance. Protocol-specific interfaces should own those lifecycle features rather than overloading synchronous invocation.
Development and provenance
go vet ./...
go test ./...
go test -race ./... # requires a supported C toolchain
go build ./cmd/skill-cli
Tests exercise stdio, Streamable HTTP and legacy SSE against the official Go MCP SDK, nested JSON, session retention, tool errors, OpenAPI validation/encoding, HTTP deadlines and size limits, redirect/credential boundaries, gateway authentication/allowlists, and CLI output. CI runs on Linux, Windows, and macOS, with a Linux race check.
Credential tests use isolated stores and synthetic secrets, including command failure/redaction, rotation, all three MCP transports, destination binding rejection and dry-run non-invocation. python scripts/credential_smoke.py exercises compiled environment-backed calls against a local fixture; add --keyring to create/rotate/delete one disposable OS item. CI runs that OS check on Windows only; Linux/macOS unit tests do not require unlocking a real store. Nothing contacts a provider account or reads real user tokens.
The hands-on evaluation explains the ranking and implementation choices. Design references: UXC for protocol adapters and compact discovery, mcpc for session lifecycle and error semantics, MCPorter for embedding/code generation, and mcp-cli for a small agent-facing command surface. This implementation uses the official Go MCP SDK and kin-openapi; it does not copy the reference projects' implementations.
Agent skill and native-MCP benchmark
The reusable skill-cli skill teaches progressive discovery, schema inspection, portable JSON input, failure handling, and gateway use. Install the skills/skill-cli folder into your agent's skills directory; for Codex the usual destination is ~/.codex/skills/skill-cli.
The benchmark suite now includes 10 public MCP servers, two OpenAPI sources, 46 operations and 80 labeled tasks, an official-SDK native MCP peer, frozen catalog replay, retrieval metrics, token-component counts, live read-only probes, and a three-arm model-selection runner with provider-reported token usage. Read the expanded results and the historical three-server baseline before interpreting savings or precision/recall. Model accuracy and billed cost require a configured model endpoint; tokenizer counts are not billing measurements.
Directories
¶
| Path | Synopsis |
|---|---|
|
benchmarks
|
|
|
cmd/mcp-peer
command
mcp-peer is a JSONL benchmark driver using the official SDK directly for MCP.
|
mcp-peer is a JSONL benchmark driver using the official SDK directly for MCP. |
|
cmd
|
|
|
skill-cli
command
|
|
|
examples
|
|
|
demo-server
command
A local, credential-free server for trying MCP and HTTP invocation.
|
A local, credential-free server for trying MCP and HTTP invocation. |
|
internal
|
|
|
catalog
Package catalog implements the authenticated three-interface skill gateway.
|
Package catalog implements the authenticated three-interface skill gateway. |
|
credentials
Package credentials resolves operator-configured secret references.
|
Package credentials resolves operator-configured secret references. |
|
oauthclient
Package oauthclient implements explicit, local OAuth login for remote MCP.
|
Package oauthclient implements explicit, local OAuth login for remote MCP. |