-
Notifications
You must be signed in to change notification settings - Fork 133
Codify MCP tool name requirements and add title #152
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: main
Are you sure you want to change the base?
Changes from all commits
6835f7a
843d9cb
b63a48e
297f15c
d7254ba
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 |
|---|---|---|
|
|
@@ -118,6 +118,15 @@ A <dfn>tool definition</dfn> is a [=struct=] with the following [=struct/items=] | |
| :: a [=string=] uniquely identifying a tool registered within a [=model context=]'s [=model | ||
| context/tool map=]; it is the same as the [=map/key=] identifying this object. | ||
|
|
||
| The [=tool definition/name=] SHOULD: | ||
| * Have a [=string/length=] between 1 and 128, inclusive. | ||
| * Be considered case-sensitive. | ||
| * Only consist of [=ASCII alphanumeric=] [=code points=], U+005F LOW LINE (_), U+002D HYPHEN-MINUS (-), and U+002E FULL STOP (.). | ||
|
|
||
| : <dfn>title</dfn> | ||
| :: A [=string=] representing a human-readable title of the tool to be used in the user interface | ||
| to represent the tool. If not provided, the [=tool definition/name=] is used as the default display value. | ||
|
|
||
| : <dfn>description</dfn> | ||
| :: a [=string=]. | ||
|
|
||
|
|
@@ -206,12 +215,18 @@ The <dfn method for=ModelContext>registerTool(<var>tool</var>)</dfn> method step | |
|
|
||
| 1. Let |tool name| be |tool|'s {{ModelContextTool/name}}. | ||
|
|
||
| 1. Let |tool title| be |tool|'s {{ModelContextTool/title}}. | ||
|
|
||
| 1. If |tool map|[|tool name|] [=map/exists=], then [=exception/throw=] an {{InvalidStateError}} | ||
| {{DOMException}}. | ||
|
|
||
| 1. If either |tool name| or {{ModelContextTool/description}} is the empty string, then | ||
| 1. If |tool name| or {{ModelContextTool/description}} is an empty string, then | ||
| [=exception/throw=] an {{InvalidStateError}} {{DOMException}}. | ||
|
|
||
| 1. If |tool name|'s [=string/length=] is greater than 128, or if |tool name| contains a | ||
| [=code point=] that is not an [=ASCII alphanumeric=], U+005F (_), U+002D (-), or U+002E (.), | ||
| then [=exception/throw=] an {{InvalidStateError}}. | ||
|
|
||
| 1. Let |stringified input schema| be the empty string. | ||
|
|
||
| 1. If |tool|'s {{ModelContextTool/inputSchema}} [=map/exists=], then set |stringified input schema| | ||
|
|
@@ -240,6 +255,9 @@ The <dfn method for=ModelContext>registerTool(<var>tool</var>)</dfn> method step | |
| : [=tool definition/name=] | ||
| :: |tool name| | ||
|
|
||
| : [=tool definition/title=] | ||
| :: |tool title| | ||
|
|
||
| : [=tool definition/description=] | ||
| :: |tool|'s {{ModelContextTool/description}} | ||
|
|
||
|
|
@@ -275,6 +293,7 @@ The {{ModelContextTool}} dictionary describes a tool that can be invoked by [=ag | |
| <xmp class="idl"> | ||
| dictionary ModelContextTool { | ||
| required DOMString name; | ||
| DOMString title; | ||
| required DOMString description; | ||
| object inputSchema; | ||
| required ToolExecuteCallback execute; | ||
|
|
@@ -294,6 +313,13 @@ callback ToolExecuteCallback = Promise<any> (object input, ModelContextClient cl | |
| <p>A unique identifier for the tool. This is used by [=agents=] to reference the tool when making tool calls. | ||
| </dd> | ||
|
|
||
| <dt><code><var ignore>tool</var>["{{ModelContextTool/title}}"]</code></dt> | ||
| <dd> | ||
| <p>A label for the tool. This is used by the user agent to reference the tool in the user interface. | ||
|
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. Regarding internationalization: should we add a note advising developers to localize the title based on the user's language settings?
Collaborator
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. Does MCP encourage something similar?
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. There is no explicit rule in the spec that says "titles MUST be localized." BUT since those are not passed to the LLM but only for display purposes to the user, it'd make sense to provide them in the browser user language. Thoughts?
Author
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. For now added a line to the non-normative ModelContextTool Dictionary section that states 'It is recommended that this string be localized to the user’s language.' |
||
| <p>It is recommended that this string be localized to the user's | ||
| {{NavigatorLanguage/language}}. | ||
| </dd> | ||
|
|
||
| <dt><code><var ignore>tool</var>["{{ModelContextTool/description}}"]</code></dt> | ||
| <dd> | ||
| <p>A natural language description of the tool's functionality. This helps [=agents=] understand when and how to use the tool. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.