pi-mono/packages/coding-agent/scripts
Christian Klotz 9171697c0d
feat(mcp,coding-agent): publish a JSON schema for mcp.json (#12706)
Publishes a JSON schema for `mcp.json` at
`https://pi.dev/schemas/mcp.schema.json`, like the existing
models/settings/keybindings/theme schemas. Closes #12563.

## What

**pi-mcp** (owner of the shared `mcpServers` shape):
- New `./config-schema` export: the shared fields as a JSON Schema built
with pi-schema, following the pi-ai compat/model-schema pattern.
Field-level constraints (loopback `callbackUrl`, non-blank `clientName`,
port bounds, URL patterns, `protocol`) live here, next to the validator
they mirror.
- `McpStdioServerConfig`, `McpHttpServerConfig`, and `McpOAuthConfig`
now derive from the schema (`Static`), so schema and types cannot drift.
`McpHttpServerConfig.type` now includes `"streamable-http"`, which the
validator always accepted. The validator itself is unchanged, and the
root export does not load pi-schema (type-only imports).

**coding-agent**:
- `src/core/mcp-config-schema.ts` composes pi's fields (`exposure`,
`toolExposure`, `auth`, `autoEnableCodemode`, project override entries)
on top of pi-mcp's property maps, re-annotated with pi's behavior, and
`generate-schemas.ts` emits the committed `schemas/mcp.schema.json`.
- Entries, oauth, and the document root are closed objects: the loader
deliberately keeps unknown fields, so a mistyped key (`exposur`,
`mcpSevers`) changes behavior silently today; the schema flags it in the
editor.
- Docs: `$schema` line in `docs/mcp.md`, plus a section for the
previously undocumented `auth` field (separate commit).

## Intentional schema/runtime differences

Documented in the `mcp-config-schema.ts` header and asserted in the
tests: cross-field rules stay prose (override/`auth` file scoping, cimd
restrictions, port agreement), URL schemes must be lowercase, and
entries mixing `url` with `command` are flagged although the runtime
picks HTTP.

## Tests

- `packages/mcp/test/config-schema.test.ts`: schema/validator agreement
for the shared fields.
- `packages/coding-agent/test/config-schemas.test.ts`: fifth artifact
pinned, representative documents, a runtime-validator agreement test
(accept and reject lists plus the documented asymmetries), and a
compile-time key-parity guard against the runtime config types.
- `npm run check` clean; pi-mcp suite 199/199; coding-agent
config-schemas/documentation/references pass.

This PR is AI-generated.
2026-12-01 15:59:26 +00:00
..
generate-references.ts docs(ai,coding-agent): generate models.json reference from schemas (#11038) 2026-10-16 21:53:00 +01:00
generate-schemas.ts feat(mcp,coding-agent): publish a JSON schema for mcp.json (#12706) 2026-12-01 15:59:26 +00:00
migrate-sessions.sh fix: use portable shebang in shell scripts 2026-01-22 21:44:39 +01:00