Skip to content

Docs MCP: get_edge_component tool, and keep event names in get_page - #541

Draft
simonhamp wants to merge 1 commit into
mainfrom
feat/mcp-element-props
Draft

simonhamp wants to merge 1 commit into
mainfrom
feat/mcp-element-props

Conversation

@simonhamp

Copy link
Copy Markdown
Member

In our todo app benchmark, agents with the docs MCP enabled called list_edge_components a few times, then gave up and read vendor source for element props. ListItem.php alone was opened 9 times. Two things were behind that.

The first is a bug. get_page and search_docs run prose through a Blade cleaner that removes every @word. That includes inline code, so the Events section of every EDGE page came through the MCP as:

- `` - Component method to call when tapped

You can see it now with get_page mobile/4/edge-components/button. No event name (@press, @change, @submit) was ever visible through the MCP. The cleaner now leaves inline code spans alone and unescapes them the way Blade renders them (@{{ $x }} shows as {{ $x }}). Fenced code was already kept.

The second is a missing tool. list_edge_components only gave page titles, and sub-elements like <native:list-item> or <native:outlined-text-input> don't have pages of their own. So:

  • New get_edge_component tool. Pass a tag (list-item, <native:list-item>, list_item and ListItem all work) and it returns that element's props, events, children and fluent API, plus the PHP class and a note that v4 elements need nativephp/mobile-ui registered. Examples are left out and it points at get_page for them.
  • For a sub-element documented in its own H2 (List Item, List Section, Rect) you get that section plus its ListItem methods block from the Element section. For a page-level element you get the page minus Examples and minus any sub-element sections.
  • list_edge_components now prints the tags each page documents and mentions the new tool. The REST listing gets a tags array, and there's a new /api/mcp/edge-components/{platform}/{version}/{tag}.

The tag map is built from the docs markdown itself: an H2 named after the tag, then the page slug, then the page that names the tag most in prose (only if it also appears in that page's code). So it follows the docs as they change. It works for core-backed elements (column, text, rect) and mobile-ui ones the same way. The page cache key moves to v3 so pages cached with the stripped prose aren't reused.

How I tested: new cases in DocsMcpServerPageTest cover the tool, the spellings, the unknown-tag error, the list output, REST, and that @press survives get_page. One test walks every catalogued tag and checks it resolves to a non-empty reference and a page get_page can open. McpSecurityTest gets a traversal case for the new route. The full suite passes apart from SupportTicketTest > only internal notes can be pinned, which is flaky and fails on main too.

What to watch: the reference is only as good as the page. The docs PR #539 fixes the list-item and text-input gaps agents hit, and this reads straight from those pages. video-player shows up as a tag on the pager page because the pager docs use it. That seemed more useful than hiding it.

🤖 Generated with Claude Code

get_page and search_docs ran prose through a Blade cleaner that removed
every @word, including inline code like `@press` and `@change`. Event
lists came out as "- `` - Component method to call when tapped", so
agents opened vendor source to find event names. Inline code spans are
now kept and unescaped the way Blade renders them.

get_edge_component returns one element's props, events, children and
fluent API from its docs page, without the examples. Sub-elements like
list-item get their own section plus their fluent methods.
list_edge_components and the REST listing now name the tags each page
documents. The tag to page map is built from the markdown, so it can't
drift from the site.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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