feat(fred): plugin scaffold, API client, guided errors, CI - #36
Merged
Conversation
First PR of the fred plugin stack (#30). No tools yet: this is the base the four later PRs sit on, plus the CI that gates them. - client.py resolves FRED_API_KEY from the environment or ~/.fred-mcp/credentials.json, checks the key's shape locally so a pasted-wrong key names the real problem instead of returning FRED's message about "variable api_key", and backs off on 429 and 5xx. The key is never echoed in any error. - errors.py maps failures to {error, suggestions}. FRED puts the real reason in the body rather than the status (a bad series ID and a bad units code are both HTTP 400), so error_message is what drives the suggestions. - The server reads its version from plugin.json rather than hardcoding it, so it cannot drift from the manifest the plugin-version workflow enforces. - On mcp 2.0, where FastMCP is renamed MCPServer. tastytrade is still on 1.x. Verified the launcher end to end: initialize and tools/list over stdio with a minimal PATH, stdout clean.
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31. First PR of the
fredplugin stack (#30).No tools yet, on purpose. This is the base the four later PRs sit on, plus the CI that gates them.
What's here
src/client.pyresolvesFRED_API_KEYfrom the environment, then~/.fred-mcp/credentials.json. It checks the key's shape locally, because FRED's own message for a bad key is "The value for variable api_key is not a 32 character alpha-numeric lower-case string", which does not tell you that you pasted it with a trailing quote. The key is never echoed in anything raised from there. 429 and 5xx back off; 400 does not, since it is the caller's problem.src/errors.pyturns every failure into{error, suggestions}. The FRED-specific part: the real reason lives in the response body, not the status. A missing series and a badunitscode are both HTTP 400 and onlyerror_messagetells them apart, so the suggestions key off the body:{ "error": "FRED rejected the request: Bad Request. The series does not exist.", "suggestions": [ "The series ID is wrong or the series has been discontinued.", "Find the right one with search_series, which returns IDs ordered by popularity.", "IDs are case-sensitive and uppercase, e.g. UNRATE, CPIAUCSL, GDPC1, DFF." ], "status_code": 400 }src/server.pyreads its version fromplugin.jsoninstead of hardcoding it, so it cannot drift from the manifest theplugin versionworkflow requires be bumped.Two deliberate differences from tastytrade
FastMCPis renamedMCPServer. The decorator API is otherwise identical. tastytrade is on 1.26; new plugin, so no reason to start on the old name.tool.uv.package = falseinstead of a build backend. tastytrade ships atastytrade-mcpconsole script that has never worked (thesrcflattening breaks its relative imports), andstart-server.shworks around it by running the module directly. Skipping the packaging metadata entirely removes the trap rather than documenting it.Verification
make checkandmake coveragepass, 38 tests, 96% coverage. The launcher was driven end to end with a minimal PATH:initializeandtools/listover stdio, empty tool list, and stdout clean (a single stray print there corrupts the protocol and surfaces to the user as a parse error).The test suite forces a dummy
FRED_API_KEYand repoints the credentials-file fallback at a tmp dir, so nothing here can reach the real API or pick up a developer's own key.