Live API specs for coding agents
Live API specs for coding agents An agent writing frontend code has to know the backend's API. It has three options. It can read the backend source and work out from scratch what the service already publishes. It can ask you, which promotes you to API documentation. Or it can swallow the entire OpenAPI document in order to use one route out of it. Then it does the same thing again tomorrow,…
The article discusses an innovative tool called docs-mcpserver that simplifies the process of coding frontend agent applications by providing live API specifications. The tool allows an agent to access the backend's API in three ways: by reading the backend source, by asking the agent (promoting the agent to API documentation), or by using an OpenAPI document.
To use docs-mcpserver, the agent first retrieves a cached OpenAPI document from the running service. The cached spec is then served one operation at a time, allowing the agent to focus on the specific operation it needs rather than the entire document. The agent can search for the required operation by definition name or keyword search.
Using docs-mcpserver offers several advantages. First, it reduces the amount of code the agent needs to work with, keeping it focused on the operation it's working on. Second, the cached spec is always up-to-date, even if the service grows or changes over time. Third, the agent can continue building the frontend even if the backend is not running, as all calls are answered from the cached spec.
If the backend service is unavailable or does not provide a valid spec, the last known-good copy of the spec is served, ensuring uninterrupted development. The tool is open-source and available on GitHub and npm.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.