๐ ๏ธ From Theory to a Working MCP Server
In January 2026 I wrote three exploration notes on how the Model Context Protocol (MCP) could work for Pyxel. This article looks back at them now that the idea is a real, published tool.
Summary: My January walkthrough described a hypothetical, read-only
MCP server for Pyxel. It became pyxel-config-core, the validation and
knowledge core of Pyxel Config Lab, callable as a Python library, a command line tool
or an MCP server. This article goes through each January idea and says what was built,
what changed between design and build, and what was left out.
Project:
pyxel-config-core on PyPI
ยท
documentation
ยท
source (MIT)
January notes: Exploring MCP, the theoretical walkthrough and the reference materials.
๐ Overview
The January notes ended with "next steps: small prototypes". The prototype grew into
a package with one implementation and three ways in: a Python library, the
pyxel-config command line tool and an MCP server. Whatever the command
line says about a configuration, the MCP tool says too, because both call the same code.
It reads the same bundled files as the browser Lab: Pyxel's JSON Schema, the model-parameter catalogue and the tutorial library. The Lab and the core cannot drift apart, because neither has its own copy of the rules.
๐งฉ The January Ideas, One by One
| January idea | What was built |
|---|---|
| 1. Schema exposure |
Validation runs against the JSON Schema of a pinned Pyxel release, bundled
with the package. Every result names that release in
pyxel_version, so a verdict is never separated from the rules
that produced it.
|
| 2. Configuration validation | validate_pyxel_config and explain_pyxel_config
accept a config or a raw YAML string and return structured diagnostics, each
explained with a one-sentence summary and a next step. On the command line,
the exit code is the verdict, and results can be written as JSON, SARIF or
GitLab Code Quality reports for CI.
|
| 3. Reference examples | get_pyxel_model_parameters lists every argument a model takes,
with its type, whether it is required, Pyxel's own default and the example
value Pyxel's example configs use.
|
| 4. Model and detector metadata | list_pyxel_models lists every valid model, optionally for one
pipeline stage, read from the same schema the validator uses, so an assistant
can find a real model name instead of guessing one.
|
| 5. Documentation search | get_pyxel_tutorial, search_pyxel_tutorials and
semantic_search_pyxel_tutorials return real tutorial passages to
cite. When the vector index is missing, semantic search falls back to keywords
and says so with a degraded flag, rather than failing.
|
| 6. Visualization hooks | Left out of the server. The visual side lives in the browser Lab, which reads the same bundled files. |
๐ What Changed Between Design and Build
- It does more than read. January assumed a read-only server.
fix_pyxel_confignow repairs model names: it renames a mistyped model to its nearest valid match and moves a model into the stage it belongs to. It still changes nothing on disk. It returns a corrected copy with a log of every change, and it never invents required arguments. - Pyxel itself is optional. January assumed the server would run
alongside Pyxel. Because validation reads the bundled schema, the package needs
only
jsonschema,pyyamlandpydantic, so it installs quickly and runs in CI without Pyxel. - The schema had gaps of its own. Building a validator on Pyxel's schema showed where the schema and Pyxel disagree. Those findings became merge requests to Pyxel itself, listed on the Code page.
๐ The Security Principles, in Practice
The January notes said an AI agent connected to real tools should be treated as an untrusted intermediary. In the server, that became concrete rules:
- Nothing runs by default. Validation compares a configuration with the schema and never executes it.
- The deep check is opt-in. A
deepcheck hands the config topyxel.load(), which catches limits the schema cannot express. Loading runs part of a configuration, and an assistant can pass in one from an issue, an email or a web page. So the server only allows it when the person who starts it chooses--allow-deep. - Even then, only plain data. Values Pyxel would evaluate, unpickle or open are refused unless they are plain data.
- Schema-checked on both sides. Every input and output is a Pydantic model, so results are structured and checked in both directions.
โ The Open Questions, Answered
- How granular should the exposed context be? Eight tools, each doing one job: validate, explain, fix, list models, model parameters, and three ways to find tutorials.
- How do schema and documentation stay in sync? One script refreshes the bundle from a Pyxel release, and CI runs it in check mode, so the bundle cannot silently fall behind.
- What prevents outdated guidance? Every verdict carries the Pyxel release its schema came from, so a reader always knows which version the answer is about.
๐ Alongside ESA's Own MCP Server
The ESA Pyxel team has its own MCP server,
pyxel-mcp.
The two work in different ways and complement each other. ESA's server runs
pyxel.load() in the user's own Pyxel installation, so it follows whichever
version is installed, and it adds output-size estimates and an index of example
notebooks. Mine checks configurations against a pinned schema without needing Pyxel
installed, which suits continuous integration, and it adds explanations, automatic
fixes, model parameters and the browser Lab.
๐ What I Learned
Writing the theory first helped. The January principles (read-only by default, schema first, Pyxel as the single source of truth, the AI as an untrusted intermediary) all survived into the build. What I could not have predicted on paper was how much the build would teach me about Pyxel's own schema.
โ๏ธ Authored by: Doby Baxter
๐ง Category: AI & MCP Exploration Notes