Open
Conversation
…erministic builds
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.
Issue
When testing SerpApi MCP (currently deployed server at mcp.serpapi.com), I found out that the
readoperation on MCP resources for all engines was failing.When tested with the official MCP inspector tool, this was confirmed.
Also, this CURL request can be used to reproduce the issue.
Any dummy value can be used in place of the API Key for testing (In the above example, I used
123in place of the key) since we are running MCP-level operations and no actual SerpApi requests are performed. The same failure occurs even with a working API key.The bug
This was an interesting bug. I tried replicating the issue locally, but everything was working well locally. Looking at the latest FastMCP docs (https://gofastmcp.com/servers/resources#the-@resource-decorator), I saw that MCP resources are now recommended to be returned as raw strings or as the newly introduced
ResourceResulttype.Currently, our repo returns resource results as Python dictionaries.
I checked whether this was causing an error in 2.* versions of FastMCP, as well as the latest version (3.2.4) - the bug was not present, and everything worked perfectly.
The real issue was that our latest deployment was on 12th March, and the FastMCP version, which was the latest at that time (v3.2.0), had the return types strictly enforced. The version expects a string output, but we were returning a dict (
return json.loads(engine_path.read_text())), which was previously supported.We were using
uv synccommand in our Dockerfile without copying UV lockfile, and this caused the latest available version of packages to be installed at deployment time.The issue can be reproduced locally by:
Fixes
This PR does the following as fixes/enhancements to our current flow. A simple update/redeploy will be enough to fix the issue for now, but the steps below were taken for future-proofing.
Added UV lockfile to Docker and use
uv sync --lockedto install exact package versions from the lockfile. This will help with deterministic installs and help prevent new supply chain vulnerabilities on redeployments.Upgraded FastMCP to the latest version: The version added new explicit types to express MCP Resource outputs.
ResourceResultobjects are used to wrap responses of MCP resource calls. This makes the implementation more explicit. Ref: https://gofastmcp.com/servers/resources#resourceresultExplicit tool description: The latest version of FastMCP was stripping the tool description supplied as a Python docstring. I have extracted the tool description into a new variable and made a few edits to improve clarity and align the terminology with the MCP specification. Then passed this explicitly to the tool decorator (as
@mcp.tool(description=search_tool_description)).Looking forward to your thoughts on these changes.
Also bumped the project's version to 0.3.0.
Testing the implementation
Future Enhancements