Skip to content

feat: add tool execution properties to Tool - #567

Merged
devcrocod merged 4 commits into
mainfrom
devcrocod/tool-execution-in-tool-def
Mar 10, 2026
Merged

feat: add tool execution properties to Tool#567
devcrocod merged 4 commits into
mainfrom
devcrocod/tool-execution-in-tool-def

Conversation

@devcrocod

@devcrocod devcrocod commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

closes #543

How Has This Been Tested?

unit

Breaking Changes

binary compatibility in the Tool class

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@devcrocod
devcrocod marked this pull request as ready for review February 26, 2026 22:24
@devcrocod
devcrocod requested review from Copilot, e5l and kpavlov February 26, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for MCP “tool execution” metadata in the Kotlin SDK so tools can advertise task-augmented execution capabilities (issue #543).

Changes:

  • Introduces ToolExecution + TaskSupport and adds optional execution to Tool.
  • Extends Server.addTool(...) overload to accept execution and pass it into the registered Tool.
  • Adds serialization/deserialization unit tests and updates API dumps (plus adds detekt baseline files).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/Server.kt Extends addTool overload to accept/pass ToolExecution.
kotlin-sdk-server/api/kotlin-sdk-server.api Updates public API surface for the new addTool signature.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/ToolsTest.kt Adds unit tests for ToolExecution and Tool.execution JSON round-trips.
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types/tools.kt Adds Tool.execution, new ToolExecution model, and TaskSupport enum.
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt Adjusts deprecated Tool(...) wrapper callsite to use named meta argument.
kotlin-sdk-core/detekt-baseline-test.xml Adds a detekt baseline for tests (currently appears unused/stale).
kotlin-sdk-core/detekt-baseline-commonTestSourceSet.xml Adds a detekt baseline for commonTest source set (currently appears unused).
kotlin-sdk-core/api/kotlin-sdk-core.api Updates public API surface for new types and Tool signature changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kotlin-sdk-core/detekt-baseline-test.xml Outdated
Comment thread kotlin-sdk-core/detekt-baseline-test.xml Outdated
e5l
e5l previously approved these changes Feb 27, 2026

@kpavlov kpavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @devcrocod !

Almost perfect, but let's address @copilot findings, especially breaking changes, KDoc discrepancy and baseline cleanup suggestions.
Let's not inflate detekt baseline files: they should only shrink.
Let's maintain PR description accurate and informative.

<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>LargeClass:ToolsTest.kt:ToolsTest</ID>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is a legitimate finding. Let's split ToolsTest for maintainability instead of suppressing warning.

  2. In general, let's not add anything to baselines. Only remove. In exceptional cases let's use @Suppress annotation in place

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. currently, our approach is to group unit tests by entity for types. Splitting ToolsTest into separate files would increase complexity and make the structure less clear
  2. ideally, we should avoid adding @Suppress annotations from third-party tools into the source code. For now, I've added this to baseline, which is also not the best solution. If you see a better approach, I'd appreciate your suggestion

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This method might not be the best fit when the group gets too large.

Splitting ToolsTest into separate files would increase complexity and make the structure less clear

Actually, it is often the other way around. Smaller files are usually easier to understand and keep up with. This one is over 500 lines and checks out several classes. It could be broken down into smaller pieces, so let’s do that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Ideally, we should avoid situations where @Suppress is needed.

There is one exception: when we are clearly explaining our design choice to NOT follow best practices. We can add a comment to clarify this. If it is in the code, it is easy to see whether it is a false positive or not. But if it is in the baseline file, it’s separate from the code.

Let’s focus on removing baseline files rather than adding more to them.

I’m afraid I won’t be able to give +1 on this.

@devcrocod devcrocod mentioned this pull request Mar 2, 2026
9 tasks
@devcrocod
devcrocod force-pushed the devcrocod/tool-execution-in-tool-def branch from 29e3d1b to 1cc2a16 Compare March 2, 2026 18:58
@devcrocod
devcrocod requested review from Copilot and kpavlov March 2, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter

codecov-commenter commented Mar 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../io/modelcontextprotocol/kotlin/sdk/types/tools.kt 85.71% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@kpavlov kpavlov mentioned this pull request Mar 3, 2026
6 tasks
kpavlov
kpavlov previously approved these changes Mar 3, 2026

@kpavlov kpavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devcrocod, ok please check the #582 and consider removing unnecessary baselines

kpavlov added a commit that referenced this pull request Mar 3, 2026
- Updated `detekt.yml` to exclude test folders from
`EmptyFunctionBlock`, `LargeClass`, and `LongMethod` checks.
- Cleanup detekt-baseline files.
- Simplified `.idea/detekt.xml`.

## Motivation and Context
To reduce linter noise and reduce tension

## How Has This Been Tested?
`./gradlew detekt`

## Breaking Changes
No

## Types of changes
- [x] Build tool/ci update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [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
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context

#567
@devcrocod
devcrocod force-pushed the devcrocod/tool-execution-in-tool-def branch from d506636 to c84eeba Compare March 10, 2026 11:38
@devcrocod
devcrocod requested a review from kpavlov March 10, 2026 12:03

@kpavlov kpavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI review requested due to automatic review settings March 10, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@devcrocod
devcrocod merged commit 338f948 into main Mar 10, 2026
18 of 19 checks passed
@devcrocod
devcrocod deleted the devcrocod/tool-execution-in-tool-def branch March 10, 2026 19:05
@kpavlov kpavlov mentioned this pull request Apr 2, 2026
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.

Add ToolExecution to Tool definition

5 participants