feat(server): add tool name validation per SEP-986 (#695)
Add warn-only validation for tool names at registration time, following the MCP tool naming standard (SEP-986) closes #417 ## How Has This Been Tested? unit tests ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed
This commit is contained in:
parent
61fab2ffe0
commit
e74ef2db6f
1 changed files with 196 additions and 1 deletions
|
|
@ -98,6 +98,16 @@ class ServerToolsTest : AbstractServerFeaturesTest() {
|
|||
assertFalse(toolListChangedNotificationReceived, "No notification should be sent when tool doesn't exist")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `addTool should succeed with non-conforming tool name`() = runTest {
|
||||
server.addTool("my invalid tool!", "Tool with non-conforming name", ToolSchema()) {
|
||||
CallToolResult(listOf(TextContent("It works")))
|
||||
}
|
||||
|
||||
val result = server.removeTool("my invalid tool!")
|
||||
assertTrue(result, "Tool with non-conforming name should have been registered and removable")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `removeTool should throw when tools capability is not supported`() = runTest {
|
||||
var toolListChangedNotificationReceived = false
|
||||
|
|
|
|||
Loading…
Reference in a new issue