Repository navigation
feat: serve Deepgram's agent skills over the MCP Skills extension - #16
dg-dayhaysoos wants to merge 12 commits into
Conversation
A fresh install resolved mcp to 2.x, where streamablehttp_client no longer exists, so every start failed with an ImportError. CI did not notice because it installs from uv.lock, which still pinned mcp 1.27.0. - Port the proxy to the 2.x client and low-level server API, and require mcp>=2.3.0,<3 so the next major cannot break installs the same way. - Report the installed package version as serverInfo.version instead of a hard-coded 0.1.10. - Add end-to-end tests that run a real MCP client against the real proxy with an in-memory remote, and a CI job that installs without the lockfile. Tool proxying is unchanged: the tool list is read from the remote once at startup, calls forward the name and arguments, and only the content blocks of the remote's answer are returned. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every GET /sse answered 500, on MCP SDK 1.x as well as 2.x: the handler read request.send, which Starlette's Request does not have. POST /messages would have failed next, because Route wrapped the transport's ASGI method as a request handler. The existing tests replace Starlette and uvicorn with mocks, so nothing exercised either route. Serve both endpoints as raw ASGI apps, and add end-to-end tests that connect an SSE client to the running server. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The proxy returned only the content blocks of a tool call and dropped structuredContent and isError. The remote's one tool, search_deepgram_knowledge_sources, declares an outputSchema, so every call failed: on MCP SDK 1.x the server answered "Output validation error: outputSchema defined but no structured output returned", and on 2.x a validating client rejects the result. Return the remote's CallToolResult unchanged. A remote tool error now also arrives as an error instead of a success. Verified with a real call through the proxy to api.dx.deepgram.com. The fake remote in the tests now declares an output schema, as the real tool does. Fixes #12. This is the change proposed in #15, carried over to the SDK 2.x handler. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Ship a copy of Deepgram's agent skills inside the package, so that they can be served from an install with no network access. - SKILLS_REVISION pins the commit of deepgram/skills to copy. It is 02bc27cb, the commit tagged deepgram-skills-v1.8.0: 14 skills, 26 files. - scripts/sync_skills.py downloads that commit and regenerates src/deepgram_mcp/bundled_skills/, with a SOURCE.json that records the revision and the SHA-256 digest of every file. --check compares without writing. The copy is never edited by hand. - The files are package data, and .gitattributes stops Git converting their line endings, since they are served byte for byte. Nothing reads the files yet; the next commit serves them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An agent that runs deepgram-mcp now gets Deepgram's skills with no separate install. They are served from the copy bundled in the package, using the io.modelcontextprotocol/skills extension (beta): - The server declares the extension and the resources capability. - skills/list and skills/get return an entry per skill: the URI of its SKILL.md, its frontmatter unchanged, and a manifest of every file with a SHA-256 digest and a size, computed from the bytes that are served. - resources/read serves each file under skill://<skill>/<path>, and resources/list shows the files to clients without the extension. - Results carry resultType, ttlMs and cacheScope. An unknown skill or file is answered with -32602. The MCP SDK release this runs on (2.3.0) has no support for the extension, so the two methods are custom request handlers, kept in one module. Tool proxying is unchanged, and if the skills cannot be loaded the tools are still served. Tests run a real client against the real proxy over stdio and SSE: they list the skills, fetch each one, read every file and check its digest and size against the bytes returned. Responses are validated against the extension's JSON schema, vendored from modelcontextprotocol/ext-skills as a test fixture. They need no API key and no network. The same handlers, served over Streamable HTTP by a scratch wrapper, pass the three skills scenarios of modelcontextprotocol/conformance at 96a6f94: 39 checks passed and 6 skipped, the skipped ones being the optional directory listing this server does not declare. The first run caught a frontmatter entry that differed from the file for a folded description on the last line; that is fixed here and has a regression test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An independent verification of this branch found no failing requirement, but four things that would bite on a future skills bump or mislead a reader. - Read frontmatter as YAML 1.2. PyYAML follows YAML 1.1, where yes, NO and on are booleans, 0755 is octal, 12:30:00 is a number and 2026-01-01 is a date. Hosts parse with YAML 1.2 and refuse a skill whose entry differs from their own parse. Duplicate keys, keys that are not strings and values with no JSON form are refused when the skills are loaded. - Serve only the files recorded in SOURCE.json. Anything else in the installed directory was served too, such as the __pycache__ that pip writes next to a Python file. - Answer resources/templates/list with an empty list. The server declares the resources capability, and clients that see it may ask. - README: the skills are served without network requests, but the server still has to connect to Deepgram with a valid key before it serves anything. It no longer says they work offline. The YAML rules were checked against the JavaScript yaml library, which the MCP conformance suite uses: 73 of 79 edge cases are identical, and the rest are refused here on purpose, apart from an explicit !!float tag. The three conformance scenarios for skills still pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
run_proxy created the remote connection, the local server and the transport in one body. Nothing could get a server without a live remote, and the tests reached inside by patching three names in the MCP SDK. It is now three steps: - _connect_remote opens the session with Deepgram's remote server. - build_server turns a remote session into the local server: the remote's tools, plus the bundled skills. The remote is an argument, so a test hands it a stand-in instead of patching. - Each transport is a function that runs a given server, chosen through the TransportType enum, which nothing used before. sse_app returns the SSE server as an ASGI app. One change in behaviour: run_proxy raises ValueError for a transport that is not stdio or sse, before it connects. It used to connect to the remote and return without serving anything. The command line already rejects such a value, so only code that calls run_proxy directly can see the difference. Tests: the mock-based tests of the proxy are gone. They replaced the whole SDK with mocks and stayed green on main while every SSE connection returned 500 and every tool call failed. conftest.py held only their fixtures. test_end_to_end.py is folded into test_proxy.py. Nothing in the proxy or skills tests is patched any more: - Most tests give build_server an in-memory stand-in for the remote and talk to the server over in-memory streams, or over SSE on a loopback port. - Three tests start the installed program as a real process, with the stand-in remote on real HTTP. They cover the command line, the URL and the API key header sent to the remote, debug output, and stdio and SSE end to end, including --host and --port. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
What makes a bundle valid was split. scripts/sync_skills.py checked that each skill has a SKILL.md, and the catalog checked every other rule only when the server started. A pin bump could write a bundle the server then refused whole, and the only signal was a warning at start. - SkillCatalog.from_files takes file contents and is the one place the rules for a skill are applied. - SkillCatalog.load(root) reads a bundle directory through its SOURCE.json. The mode that walked every file under the directory is removed: production never used it, and it is the one that served pip's __pycache__ before the last fix. A SOURCE.json that does not list files is refused by name. - The sync script loads the skills through the catalog before it writes anything. If the server could not serve one, it stops, says why, and leaves the bundled copy as it was. The script therefore imports the package, and has to be run with uv run, as the README already shows. Tests: the rules are exercised on file contents, without writing to disk. New tests cover the sync script without the download: the catalog loads the bundle the script builds, the script refuses skills the server would refuse, and the bundled copy is byte for byte what the script writes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CI failed on six of the macOS and Windows jobs: the real-process tests saw the program exit with an error, and the SSE skills tests timed out. Which jobs failed looked random. The cause is a flag in sse-starlette, which the MCP SDK streams its responses with. It keeps one flag for the whole process that says a server is shutting down, sets it when it sees a uvicorn server stop, and never clears it. From then on every streamed response in the process ends at once. It polls for the stop twice a second, so whether a test's server is seen stopping depends on timing. A program runs one server and then exits, so the product is not affected. The tests run many servers in one process. The harness now clears the flag before it starts each one. Setting the flag by hand before the tests reproduces the CI failures, test for test. With this change the same run passes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
GregHolmes
left a comment
There was a problem hiding this comment.
Requesting changes for S1 below. The rest of the content looks good.
What this does: fixes the three bugs that made deepgram-mcp unusable (crash on start with mcp 2.x, GET /sse returning 500, the search tool always erroring) and serves 14 bundled Deepgram skills over the MCP Skills extension.
What I checked:
- Does the tool work now? Yes. The installed wheel against the prod remote returned isError false and 15 structured results.
- Do the gates pass? Yes. ruff, mypy and 162 tests pass in Docker; CI is green on all 17 jobs.
- Is the bundled copy current? Yes. sync_skills.py --check passes and the pin is upstream HEAD.
- Does dg mcp break? No. The CLI vendors its own proxy and pins mcp<2.
- Does the SSE server reject foreign hosts? No. A request with Host evil.example reached session lookup.
To fix:
- [S1] proxy.py:228: pass security_settings=TransportSecuritySettings(...) to SseServerTransport so non-loopback Host/Origin are rejected. SSE returned 500 before, so this PR is what first exposes it.
- [S2] Exclude the setup-mcp skill from the bundle: it tells an agent already connected to this server to install an MCP server.
- [S3] README line 5 says dg mcp wraps deepgram-mcp; the CLI ships its own vendored proxy.
Still needs a decision: deepgram/skills has no LICENSE but this MIT package would publish its content, so add one upstream before the PyPI release. Also decide whether the mcp>=2.3.0,<3 floor needs a breaking-change marker on the release.
Not verified: no real skills-capable client has loaded these skills.
|
Follow-up to my review: I ran the skills end to end against the real remote, and found no new defects. This narrows the "not verified" line in my review. I installed the built wheel in Docker and ran it with a real Deepgram key, over stdio and over SSE.
One behavior matches the PR's own note: with the older 2025-11-25 handshake the server does not declare the Skills extension in its capabilities, but the skills/* methods still answer. Still not verified: a real skills-capable host, the 2026-07-28 server/discover handshake, and the conformance suite (author-reported only). My request for changes (S1, the SSE Host/Origin check) still stands. |
The SSE server has no authentication, and it accepted a request with any Host or Origin header. A web page can point a host name of its own at 127.0.0.1 (DNS rebinding) and reach a local server from the browser. The server now refuses a request whose Host header is not 127.0.0.1, localhost or [::1] with 421, and one whose Origin header is not one of those origins with 403. This holds for any --host value, so --host 0.0.0.0 does not make the server reachable from other machines. The MCP SDK's connect_sse answers a refused request and then raises, which the HTTP server logs as a crash. GET /sse makes the same check first and returns. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
setup-mcp tells an agent to install a Deepgram MCP server. An agent that gets the skill from this server is already connected to one. scripts/sync_skills.py now has an EXCLUDED_SKILLS list and leaves those skills out of the copy. It stops if an excluded skill is not in deepgram/skills, so a skill renamed upstream cannot come back unnoticed. The bundle was regenerated with the script: 13 skills, 25 files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The README said the Deepgram CLI's `dg mcp` wraps this package. Since CLI 0.4.1 it runs its own copy of the proxy, over stdio only, and serves the documentation search tool and not the skills. The install command is now `pipx install` or `uv tool install`. deepgram-mcp needs MCP SDK 2.3 or newer and the CLI (deepctl 0.5.0 and older) needs an MCP SDK below 2.0, so the two cannot share one Python environment: installed together with pip, `dg mcp` stops working. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@GregHolmes all three fixes are pushed.
License: deepgram/skills#27 adds an MIT license to the skills repo. Real client: Claude Code 2.1.334 connected over stdio with the 2026-07-28 handshake and listed the 13 skills. Asked a text-to-speech question, it loaded Still open: whether the |
Summary
deepgram-mcpnow serves Deepgram's agent skills with the MCP Skills extension (io.modelcontextprotocol/skills, beta), so an agent that runs the server gets the skills with no separate install. The goal is to find out quickly whether that helps agents.Getting there needed three fixes first, because the package did not work: a fresh install crashed on start, the SSE transport returned 500, and the one remote tool always returned an error. Those are the first three commits and can ship on their own.
After the skills worked, the proxy and its tests were restructured so that the tests run the real code instead of mocks. That is part 3. It changes nothing for someone who runs
deepgram-mcp.CI passes, but it has not been tried with a real skills-capable client. See "Not verified" and "Open decisions" below.
Changes
The branch is nine commits, in three parts.
Part 1: make the package work (can ship alone)
fix: start on MCP SDK 2.x. A freshpip install deepgram-mcpresolvedmcp2.x, wherestreamablehttp_clientno longer exists, so every start failed with anImportError. CI missed it because it installs fromuv.lock, which pinned 1.27.0. The proxy is ported to the 2.x API, the dependency is nowmcp>=2.3.0,<3, andserverInfo.versionis the installed package version instead of a hard-coded0.1.10. Adds a CI job that installs without the lockfile.fix: serve SSE connections. EveryGET /ssereturned 500, on SDK 1.x too. Both SSE routes are now served as raw ASGI apps.fix: return the remote's full tool result. The proxy droppedstructuredContentandisError. The remote's only tool,search_deepgram_knowledge_sources, declares anoutputSchema, so every call failed. This is the change proposed in fix(proxy): return full CallToolResult so structuredContent survives outputSchema validation #15, carried over to the SDK 2.x handler.Part 2: serve the skills
build: bundle deepgram/skills at a pinned revision.SKILLS_REVISIONpins one commit of deepgram/skills (currently02bc27cb, taggeddeepgram-skills-v1.8.0: 14 skills, 26 files).scripts/sync_skills.pyregeneratessrc/deepgram_mcp/bundled_skills/from it and writesSOURCE.jsonwith the revision and every file's digest. The copy is never edited by hand.feat: serve Deepgram's agent skills over the MCP Skills extension. New modulesrc/deepgram_mcp/skills.py:resourcescapability;skills/listandskills/getreturn, per skill, theSKILL.mdURI, the frontmatter unchanged, and a manifest of every file with a SHA-256 digest and size computed from the bytes served;resources/readserves each file underskill://<skill>/<path>;resources/listshows the files to clients without the extension;resultType,ttlMsandcacheScope; an unknown skill or file returns-32602.fix(skills): harden skill loading after an independent review. Frontmatter is read as YAML 1.2, only the files recorded inSOURCE.jsonare served,resources/templates/listanswers with an empty list, and the README no longer says the skills work offline.Part 3: structure and tests
refactor: build the local server apart from the remote connection.run_proxyused to create the remote connection, the local server and the transport in one body. It is now three steps: connect to the remote,build_server(remote), then run the server on a transport. The remote is an argument, so the tests hand it a stand-in instead of patching the SDK. The mock-based proxy tests are removed: they stayed green onmainwhile every SSE connection returned 500 and every tool call failed. One behaviour change:run_proxyraisesValueErrorfor a transport that is notstdioorsse, where it used to connect and then serve nothing. The command line already rejects such a value.refactor(skills): check skills in one place, at sync as well as at start.SkillCatalog.from_filesis the one place the rules for a skill are applied.scripts/sync_skills.pygoes through it before it writes, so a pin the server could not serve stops at the sync and leaves the bundled copy as it was. The script now imports the package, so it has to be run withuv run.test: stop one test's server shutdown from breaking later tests. A test-only fix for a CI failure that came and went. sse-starlette, which the MCP SDK uses, keeps one process-wide "shutting down" flag and never clears it; the test harness now clears it before each server it starts. The product runs one server per process and is not affected.Design choices worth a look in review
skill://api/SKILL.md. URIs are identity, so a prefix such asskill://deepgram/api/SKILL.mdshould be chosen before release if wanted.httpx2(SDK 2.x takes request headers through an HTTP client object) andpyyaml. New dev dependencies:jsonschema,types-pyyaml.tests/unit/fixtures/ext-skills/(Apache-2.0) as a test fixture. It is not part of the installed package.Test plan
uv run ruff format --check src/ tests/passesuv run ruff check src/ tests/passesuv run mypy src/passesuv run pytestpasses: 162 tests, no API key and no network beyond loopbackWhat has been confirmed
Checked at the head of the branch,
353bf23:CI: all 17 jobs pass, including the "Fresh install (no lockfile)" job and every Python 3.10 to 3.14 job on Linux, macOS and Windows. Every job ran all 162 tests with none skipped.
The 162 tests pass in the locked environment, and from the built wheel installed without the lockfile on Python 3.10 and 3.14.
The tests run a real MCP client against the real proxy, and nothing in the proxy or skills tests is mocked or patched. Most give the proxy an in-memory stand-in for the remote and reach it over in-memory streams or SSE on a loopback port, with both the older
initializehandshake andserver/discover(protocol revision 2026-07-28). They list the skills, fetch each one, read all 26 files and check digest and size against the bytes returned.Three tests start the installed program as a real process, with the stand-in remote on real HTTP. They cover the command line, the URL and API key header sent to the remote, and stdio and SSE end to end, including
--hostand--port.Breaking the proxy on purpose in six ways (wrong auth scheme, trailing slash kept, wrong port, host ignored, unknown transport accepted, debug line removed) made a test fail each time. So did making the sync script skip its check.
skills/list,skills/getandresources/readresults validate against the extension's JSON schema.Real remote: the wheel-installed
deepgram-mcp, run as a real process with a valid key, lists the remote tool, a real call returns content plus structured output, and it serves 14 skills with 26 of 26 files matching their digests. Rerun after the restructuring.The official conformance suite (modelcontextprotocol/conformance at
96a6f94): the three skills scenarios pass, 39 checks passed and 6 skipped. The skipped ones are the optional directory listing, which this server does not declare. The suite only speaks Streamable HTTP, which this package does not offer, so it ran against the server thatbuild_serverreturns, behind a scratch HTTP wrapper. Rerun after the restructuring, with the same result.The bundled files are byte-identical to deepgram/skills at the pinned commit:
scripts/sync_skills.py --checkpasses, and a real run of the script rewrites the same bytes.The restructuring was reviewed by two reviewers that had not seen it being written, one against the repo's standards and one against the plan. Neither found a code defect. The test gap and the fragile spots they found are fixed.
Checked at
f0507fc, before the restructuring, and not repeated since:Frontmatter for all 14 skills is identical to what the JavaScript
yamllibrary gives. The YAML 1.2 rules were checked against that library on 79 edge cases: 73 identical; the rest are refused here on purpose, apart from an explicit!!floattag.An independent reviewer with no knowledge of how this was built wrote its own client from the specification and checked 13 requirements: all passed. It also ran the conformance suite through an HTTP-to-stdio bridge in front of the installed binary, with the same result, confirmed the bump procedure works on two other commits, and ran the server in a loopback-only sandbox. Its four actionable findings are fixed in
fix(skills): harden skill loading after an independent review.Not verified
Open decisions
setup-mcpskill. It is served as is. It tells the agent how to install a Deepgram MCP server, including this one, which the agent is already connected to.initializehandshake can call the skills methods but do not see the extension declared (an SDK 2.3.0 limit, fixed upstream but unreleased). A Streamable HTTP transport would be the natural home for skills over HTTP; this branch does not add one. Since part 3 a transport is one function that runs a server.main, so this branch is the first to expose it. It binds to127.0.0.1by default.SOURCE.json. Onlyscripts/sync_skills.py --checkcompares with GitHub, and no workflow runs it.Error: unhandled errors in a TaskGroup (1 sub-exception). Same onmain; not changed here.test_main.pystill mocks. The command-line tests replaceasyncio.runand the signal handlers. The three real-process tests now cover the same path for real, so most of that file could go.pydantic>=2.10.1is below the SDK's own floor of 2.12. Normal installs are unaffected.Related issues
Fixes #12. Supersedes #15, which makes the same tool-result fix against the SDK 1.x code this branch rewrites.
🤖 Generated with Claude Code