docs(server): guide agents to read resources by URI, not name#1244
Open
Lothsahn wants to merge 1 commit into
Open
docs(server): guide agents to read resources by URI, not name#1244Lothsahn wants to merge 1 commit into
Lothsahn wants to merge 1 commit into
Conversation
Add a "Reading resources" section to the FastMCP server instructions string. It states that resources are addressed by URI (slashes), never by name (underscores); that the exact URI should be taken from the client's resources/list rather than constructed from the name; and that payloads are wrapped under a top-level `data` object (field paths look like data.<section>.<field>). Prevents the common naive failure where an agent turns a resource name into a URI (e.g. editor_state -> mcpforunity://editor_state) and 404s, and the matching failure of guessing a bare top-level field instead of the nested data.* path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughUpdated the generated server instructions text to clarify resource-reading guidance: resources must be addressed by URI (not name), URIs should come from ChangesInstructions text update
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
I noticed that asking Claude to read editor state often caused it to get 404 errors and have to retry to generate the right URI. With these changes in place, Claude gets the call right on the first time, every time, which makes development faster.
Description
Add a "Reading resources" section to the FastMCP server instructions string. It states that resources are addressed by URI (slashes), never by name (underscores); that the exact URI should be taken from the client's resources/list rather than constructed from the name; and that payloads are wrapped under a top-level
dataobject (field paths look like data.section.field).Prevents the common naive failure where an agent turns a resource name into a URI (e.g. editor_state -> mcpforunity://editor_state) and 404s, and the matching failure of guessing a bare top-level field instead of the nested data.* path.
Type of Change
Changes Made
Updated instructions to the agent on how to use resource URIs
Compatibility / Package Source
#beta,#main, tag, branch, orfile:): #mainPackages/packages-lock.json(if using a Git package URL): 78ee541Testing/Screenshots/Recordings
cd Server && uv run pytest tests/ -v)Text of Claude conversation:
"There are errors in the console. Please debug and solve these"
01:32 PM claude-opus-4-8
I'll start by checking the Unity console for the errors. Let me first pin the correct Unity instance for this project.
● readMcpResource(Read resource "mcpforunity://instances" from server "UnityMCP")
{
"contents": [
{
"uri": "mcpforunity://instances",
"mimeType": "text/plain",
"text": "{"success": true, "transport": "stdio", "instance_count": 2, "instances": [{"id": "xxx@e5746cd5", "name": "xxx", "path": "D:/work/xxx/Assets", "hash": "e5746cd5", "port": 6405, "status": "running", "last_heartbeat": "2026-07-05T17:32:40.083693+00:00", "unity_version": "6000.3.19f1", "project_scoped_tools": false}, {"id": "xxx2@586c3840", "name": "xxx2", "path": "D:/work/xxx2/Assets", "hash": "586c3840", "port": 6402, "status": "running", "last_heartbeat": "2026-07-05T17:32:39.927504+00:00", "unity_version": "6000.3.19f1", "project_scoped_tools": false}]}"
}
]
}
01:32 PM claude-opus-4-8
The instance for this project is xxx@e5746cd5 (path D:/work/xxx/Assets). Let me pin it and read the console.
● UnityMCP - Set Active Instance (MCP)(instance: "xxx@e5746cd5")
{
"success": true,
"message": "Active instance set to xxx@e5746cd5",
"data": {
"instance": "xxx@e5746cd5",
"session_key": "global"
}
}
● UnityMCP - Read Console (MCP)(action: "get", types: ["error"], count: 50, include_stacktrace: true, format: "detailed")
{"success":true,"message":"Retrieved 50 log entries."
Documentation Updates
tools/UPDATE_DOCS_PROMPT.md(recommended)Related Issues
None
Additional Notes
Feel free to reach out to me if you have any questions or concerns. Code changes were AI generated by Claude but I personally have reviewed, tested, and vouch for them (aka: not slop)
Summary by CodeRabbit
dataobject for easier field access.