{{ message }}
Repository navigation
Conversation
Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Complete the tool-result requirements of iflytek#1664. - Replace the generic content block with typed public models for text, image, audio, embedded resource (text/blob) and resource_link blocks, selected by a callable discriminator. Block types the service does not model are passed through as explicit `unsupported: true` blocks, and annotations, _meta and unknown fields are preserved. - Forward the top-level result _meta alongside structuredContent and the tool-level isError flag, which stays separate from the envelope code. - Keep mimeType as the standard field and document mineType as a deprecated compatibility alias on image blocks. - Dump SDK results in JSON mode so AnyUrl values (resource URIs) validate into the public schema; resource and prompt operations use the same mode. - Bound forwarded results with MCP_TOOL_RESULT_MAX_BLOCKS (default 128) and MCP_TOOL_RESULT_MAX_BYTES (default 4 MiB). structuredContent is budgeted first; anything withheld is reported in `truncation` and logged instead of being dropped silently. - Test with standard mcp.types result models, through the real FastAPI router, and re-validate the serialized JSON into the typed models. Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
FenjuFu
force-pushed
the
feat/mcp-resources-prompts
branch
from
September 19, 2026 03:48
3060884 to
7161be6
Compare
Member
Author
|
A follow-up self-review found a remaining gap before this can close #1664: The fix should include |
Include public fields, top-level metadata and truncation status in the final UTF-8 data budget. Return an explicit call error when even the omission status cannot fit. Cover metadata, serialization boundaries and the public route with regression tests. Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Member
Author
This branch has not been deployed
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.

Summary
This PR adds four plugin-link MCP operations (list/read resources, list/get prompts) and replaces the text/image-only tool-result adapter with typed, bounded content that preserves the full protocol shape.
Closes #1664. Refs #1662; this PR implements only part of #1662 (see "Remaining" below).
#1664 acceptance criteria
text/datakeep the same fields. Image blocks still carrymineType.mimeType; legacy misspelling handled explicitlymimeTypeis the standard field on image and audio blocks.mineTypeis only on image blocks, filled frommimeType, and its schema description marks it deprecated.MCPAudioBlock,MCPEmbeddedResourceBlock(text and blob contents), andMCPResourceLinkBlock. Annotations,_meta, and unknown fields are kept (extra="allow").structuredContentsurvives as JSON_metais retained when it fits; omissions are explicit indata.truncation.MCPUnsupportedBlockwithunsupported: trueand all their fields. The SDK (1.28) currently rejects unknown types while parsing, which already surfaces asMCP_SERVER_CALL_TOOL_ERRrather than silent loss.MCP_TOOL_RESULT_MAX_BLOCKS(default 128) andMCP_TOOL_RESULT_MAX_BYTES(default 4 MiB). The byte limit covers compact UTF-8 JSON for the completedata, including typed/compatibility fields, containers,_metaand truncation itself; it excludes the outercode/message/sidenvelope. Priority isstructuredContent, ordered content, then_meta. Omission is explicit throughstructuredContentOmitted,metaOmittedand block counts. If even truncation cannot fit, the call returnsMCP_SERVER_CALL_TOOL_ERRwith empty data.isErrordistinguishable from transport/session failureisErrorstays indatawith envelopecode= success. Call and transport failures use the error codes and have no content.mcp.types.CallToolResultwith every block type goes through_call_mcp_tool. It is also posted through the realmcp_routerwithTestClient, and the JSON re-validates into the same typed models.Implementation
service/community/tools/mcp/mcp_content.py(new): result conversion and limits. It is kept out ofmcp_server.pyto stay under the flake8 complexity gate.mode="json", by_alias=True. The SDK-model tests caught that the default python mode leaves resource URIs asAnyUrl, which failed the string fields. The resource/prompt operations now use the same mode.Remaining (#1662)
read_resource/get_promptpayloads. They can reuseResultLimitsonce [FEATURE] Support MCP resources and prompts for GitNexus context workflows #1662 settles the response shape.MCP_SERVER_SESSION_ERR.Validation (head 9280db7)
pytest testsincore/plugin/link: 264 passed; the MCP server module has 24 passing cases.Check core-linkandTest core-linkpassed on this head, including the repository's configured type checks. A broader local dependency-aware scan still reports pre-existing infrastructure/legacy fixture type errors outside this fix.