-
Notifications
You must be signed in to change notification settings - Fork 191
feat: map open_world ability annotation to openWorldHint #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ class McpAnnotationMapper { | |
| 'openWorldHint' => array( | ||
| 'type' => 'boolean', | ||
| 'features' => array( 'tool' ), | ||
| 'ability_property' => null, | ||
| 'ability_property' => 'open_world', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One edge from replaying old registrations:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could we add |
||
| ), | ||
| 'title' => array( | ||
| 'type' => 'string', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,30 @@ public function test_map_maps_idempotent_to_idempotenthint(): void { | |
| $this->assertTrue( $result['idempotentHint'] ); | ||
| } | ||
|
|
||
| public function test_map_maps_open_world_to_openworldhint(): void { | ||
| $annotations = array( | ||
| 'open_world' => false, | ||
| ); | ||
|
|
||
| $result = McpAnnotationMapper::map( $annotations, 'tool' ); | ||
|
|
||
| $this->assertArrayHasKey( 'openWorldHint', $result ); | ||
| $this->assertArrayNotHasKey( 'open_world', $result ); | ||
| $this->assertFalse( $result['openWorldHint'] ); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| public function test_open_world_override_takes_precedence_over_openworldhint(): void { | ||
| $annotations = array( | ||
| 'openWorldHint' => true, | ||
| 'open_world' => false, | ||
| ); | ||
|
|
||
| $result = McpAnnotationMapper::map( $annotations, 'tool' ); | ||
|
|
||
| $this->assertArrayHasKey( 'openWorldHint', $result ); | ||
| $this->assertFalse( $result['openWorldHint'], 'WordPress-format open_world should override openWorldHint value' ); | ||
| } | ||
|
|
||
| public function test_map_excludes_tool_fields_for_resource(): void { | ||
| $annotations = array( | ||
| 'readonly' => true, | ||
|
|
@@ -232,15 +256,13 @@ public function test_map_performs_light_type_validation_for_tools(): void { | |
| public function test_map_with_null_ability_property_uses_mcp_field_name_for_tools(): void { | ||
| $annotations = array( | ||
| // Fields with null ability_property should map 1:1. | ||
| // For tools, only openWorldHint and title have null ability_property. | ||
| 'openWorldHint' => true, | ||
| 'title' => 'Test', | ||
| // For tools, only title has null ability_property. | ||
| 'title' => 'Test', | ||
| ); | ||
|
|
||
| $result = McpAnnotationMapper::map( $annotations, 'tool' ); | ||
|
|
||
| // These should map 1:1 (ability_property is null) | ||
| $this->assertArrayHasKey( 'openWorldHint', $result ); | ||
| $this->assertArrayHasKey( 'title', $result ); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: small naming one. The other three WordPress-format hints are single words (
readonly,destructive,idempotent), so by that pattern this key would readopenworld. I'd leanopen_worldanyway since snake_case is more WordPress, but since it's becoming an Abilities API convention, could we settle the spelling on purpose so the adapter and the Abilities API stay in sync?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@galatanovidiu what do you mean by this part? "openWorldHint" seems very mcp-specific. IMO even if we bring support for marking Abilities that handle external data, I would assume we choose something that's semantic and self-defining to WordPress and then have MCP Adapter map it to here.
Regardless of the Abilities part of this, +1 to
open_world, and considerreadonlyan exception-to-the-rule, instead of establishing a future pattern of stripping multi-word semantics when going fromcamelCase.