Skip to content

refactor(core): move the MCP resource models into arcade-core [TOO-1931] - #917

Closed
EricGustin wants to merge 1 commit into
mainfrom
ericgustin/too-1931-mcp-resource-models-to-arcade-core
Closed

refactor(core): move the MCP resource models into arcade-core [TOO-1931]#917
EricGustin wants to merge 1 commit into
mainfrom
ericgustin/too-1931-mcp-resource-models-to-arcade-core

Conversation

@EricGustin

Copy link
Copy Markdown
Member

Part 1 of 6 in the M1 stack for Support Resources for Engine-to-Worker Leg. Linear: TOO-1931.

Why

arcade-serve needs MCP's resource shapes to serve them on the worker protocol, and it cannot import arcade-mcp-server, because the dependency runs the other way. This moves the result-shaped half of the resource surface into arcade-core and re-exports it from arcade_mcp_server.types, so both libraries read one definition.

What moved, and what did not

Moved: Result, PaginatedResult, BaseMetadata, Icon, Annotations, Cursor, Role, Resource, ResourceTemplate, ResourceContents, TextResourceContents, BlobResourceContents, ListResourcesResult, ListResourceTemplatesResult, ReadResourceResult, ReadResourceParams.

The three JSON-RPC request envelopes stay behind. ListResourcesRequest and its siblings extend JSONRPCRequest, which would pull JSONRPCMessage, Request and RequestId into arcade-core to no purpose: a transport that is not JSON-RPC carries the params object alone.

ListResourcesParams is new, because arcade-mcp-server never modelled it (PaginatedRequest.params is a bare dict[str, Any]). The class name is local; the wire shape is MCP's PaginatedRequestParams exactly.

A live bug this fixes

Resource, ResourceTemplate and ResourceContents declare meta with alias="_meta", but their config never set populate_by_name. With extra="allow", that means Resource(meta=...) was silently accepted as an extra field and serialized as "meta":

>>> Resource(uri="u", name="n", meta={"ui": {"x": 1}}).model_dump(by_alias=True, exclude_none=True)
{"name": "n", "uri": "u", "meta": {"ui": {"x": 1}}}     # and .meta reads None

No MCP client reads meta, so a developer-declared _meta.ui.csp would have vanished with no error at any layer. Result already had populate_by_name, which is why the two behaved differently. Fixed here with a regression test, since these are the models being moved.

Verification

  • 3745 passed, 1 skipped across libs/tests.
  • mypy clean on arcade-core and arcade-mcp-server.
  • New: 10 model tests in libs/tests/core/test_mcp_resources.py, plus a re-export identity test asserting the moved names are the same objects and the request envelopes stayed behind.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
libs/arcade-core/arcade_core/resource_schema.py 100.00% <100.00%> (ø)
libs/arcade-mcp-server/arcade_mcp_server/types.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

arcade-serve needs the worker format's resource shapes to serve them, and it
cannot import arcade-mcp-server because the dependency runs the other way. Move
the result-shaped half of the resource surface into arcade-core and re-export it
from arcade_mcp_server.types, so both libraries read one definition.

The request envelopes stay behind. ListResourcesRequest and its siblings extend
JSONRPCRequest, which would pull JSONRPCMessage, Request and RequestId into
arcade-core to no purpose: a transport that does not carry a JSON-RPC envelope
needs the params object alone. ListResourcesParams is added for that params
object, which arcade-mcp-server never modelled (PaginatedRequest.params is a
bare dict).

Also fixes a live serialization bug in the models being moved. Resource,
ResourceTemplate and ResourceContents declare meta with alias="_meta", but their
config never set populate_by_name, so Resource(meta=...) was accepted as an
extra field and emitted as "meta". No caller reads that key, so a
developer-declared _meta.ui.csp would have vanished with no error at any layer.
Result already had populate_by_name, which is why the two behaved differently.
@EricGustin
EricGustin force-pushed the ericgustin/too-1931-mcp-resource-models-to-arcade-core branch from b5642b7 to 1d296c5 Compare August 26, 2026 06:56
@EricGustin EricGustin closed this Aug 26, 2026
@EricGustin
EricGustin deleted the ericgustin/too-1931-mcp-resource-models-to-arcade-core branch August 26, 2026 06:57
@EricGustin

Copy link
Copy Markdown
Member Author

Superseded by #923. GitHub auto-closed this when the head branch was renamed to drop protocol vocabulary from a branch name in arcade-core's stack. Same commit, same content, scrubbed prose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant