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:
Pavel Gorgulov 2026-04-14 15:27:32 +02:00 • committed by GitHub
commit e74ef2db6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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