') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); feat!: relax tool result structuredContent type (SEP-2106) by DaleSeo · Pull Request #919 · modelcontextprotocol/rust-sdk · GitHub
Skip to content

feat!: relax tool result structuredContent type (SEP-2106) - #919

Merged
alexhancock merged 1 commit into
mainfrom
fix/tool-result-content-structured-value
Jun 26, 2026
Merged

feat!: relax tool result structuredContent type (SEP-2106)#919
alexhancock merged 1 commit into
mainfrom
fix/tool-result-content-structured-value

Conversation

@DaleSeo

@DaleSeoDaleSeo commented Jun 23, 2026

Copy link
Copy Markdown
Member

Motivation and Context

This was discovered while reviewing PR #895. Besides CallToolResult, ToolResultContent should also be typed with its structured content as Option<Value> to accommodate any JSON value.

2025-11-252026-07-28
2026-06-23 at 15 42 592026-06-23 at 15 41 47

How Has This Been Tested?

Added tests

Breaking Changes

Yes. The public field ToolResultContent.structured_content changes type from Option<JsonObject> to Option<Value>.

The green SemVer Check is a false negative due to known upstream gap: obi1kenobi/cargo-semver-checks#148

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@github-actionsgithub-actionsBot added T-test Testing related changes T-config Configuration file changes T-core Core library changes labels Jun 23, 2026
@DaleSeoDaleSeo self-assigned this Jun 23, 2026
@github-actionsgithub-actionsBot added the T-model Model/data structure changes label Jun 23, 2026
@DaleSeo
DaleSeo marked this pull request as ready for review June 23, 2026 19:56
@DaleSeo
DaleSeo requested a review from a team as a code ownerJune 23, 2026 19:56
@DaleSeoDaleSeo changed the title feat!: relax tool result structuredContent typefeat!: relax tool result structuredContent type (SEP-2106)Jun 23, 2026
@DaleSeo
DaleSeoforce-pushed the fix/tool-result-content-structured-value branch from 97d6a3d to 4dcb918CompareJune 25, 2026 23:26

#[tokio::test]
async fn test_tool_result_content_with_primitive_structured_content() -> Result<()> {
let structured = serde_json::json!(42);

@alexhancockalexhancockJun 26, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth one that loops through all the possible primitive types (string, number, boolean, null) and does the same test? This way it would catch if anyone changes it in some way that drops support for something.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, @alexhancock. I've opened #931 to bring in rstest for these repeated rmcp unit-test clusters (it also clears the existing -D warnings clippy failures on the test targets). Once #931 lands I'll come back and parametrize this with rstest so each primitive shows up as its own reported case.

@alexhancock
alexhancock merged commit b8a936c into mainJun 26, 2026
19 checks passed
@alexhancock
alexhancock deleted the fix/tool-result-content-structured-value branch June 26, 2026 18:57
@github-actionsgithub-actionsBot mentioned this pull request Jun 26, 2026
@DaleSeo
DaleSeo restored the fix/tool-result-content-structured-value branch June 26, 2026 19:06
DaleSeo added a commit that referenced this pull request Jun 26, 2026
@DaleSeoDaleSeo linked an issue Jun 26, 2026 that may be closed by this pull request
4 tasks
DaleSeo added a commit that referenced this pull request Jun 26, 2026
Re-applies #919 (reverted by #932): ToolResultContent.structured_content
becomes Option<Value> so non-object structured content is accepted,
matching CallToolResult and SEP-2106.
BREAKING CHANGE: ToolResultContent.structured_content changes from
Option<JsonObject> to Option<Value>.
DaleSeo added a commit that referenced this pull request Jun 26, 2026
Re-applies #919 (reverted by #932): ToolResultContent.structured_content
becomes Option<Value> so non-object structured content is accepted,
matching CallToolResult and SEP-2106.
BREAKING CHANGE: ToolResultContent.structured_content changes from
Option<JsonObject> to Option<Value>.
DaleSeo added a commit that referenced this pull request Jul 8, 2026
Re-applies #919 (reverted by #932): ToolResultContent.structured_content
becomes Option<Value> so non-object structured content is accepted,
matching CallToolResult and SEP-2106.
BREAKING CHANGE: ToolResultContent.structured_content changes from
Option<JsonObject> to Option<Value>.
@DaleSeoDaleSeo modified the milestone: 2026-07-28 specJul 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2026-07-28T-configConfiguration file changesT-coreCore library changesT-modelModel/data structure changesT-testTesting related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SEP-2106: Tool schemas conform to JSON Schema 2020-12

2 participants

@DaleSeo@alexhancock