Skip to content

Commit c4d0cc4

Browse files
cliffhallclaude
andcommitted
feat(sequentialthinking): trim the tool description to fit 1024 characters
The description drops its "Key features" list, which described the tool's virtues rather than when to call it, and its "Parameters explained" list, which restated the descriptions every inputSchema property already carries. It keeps the intro, "When to use this tool", and the guidance the field descriptions do not hold (adjusting totalThoughts, which fields pair for a revision or a branch, when to set nextThoughtNeeded to false). 2781 to 1009 characters, about 566 to 198 tokens (cl100k), so it fits the 1024-character cap OpenAI and Azure OpenAI put on tool descriptions. The tools/list test now asserts that cap and that every inputSchema property has a description of its own. The tool name and input schema are unchanged. Closes modelcontextprotocol#4507 Closes modelcontextprotocol#799 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 446be48 commit c4d0cc4

3 files changed

Lines changed: 39 additions & 49 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@modelcontextprotocol/server-sequential-thinking": patch
3+
---
4+
5+
Trim the `sequentialthinking` tool description from 2,781 to 1,009 characters (about 566 to 198 tokens), so it fits the 1,024-character cap OpenAI and Azure OpenAI put on tool descriptions (#799). The "Key features" and "Parameters explained" sections are gone: each parameter is still described by the input schema, which is unchanged, and the guidance those field descriptions do not carry is kept (#4507).

‎src/sequentialthinking/__tests__/tools-list.test.ts‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// annotations, input schema and output schema, exactly as the SDK emits them
44
// today. These are characterization tests. The annotations assert the values
55
// fixed in #4721 (the tool is stateful, so neither read-only nor idempotent).
6-
// The 2781-character description (#799) is pinned as current design: the
7-
// 1024 cap is an OpenAI/Azure client limit, not the MCP spec.
6+
// The description is held to the 1024-character cap OpenAI and Azure OpenAI
7+
// put on tool descriptions (#799), and leaves explaining each parameter to the
8+
// input schema's own field descriptions (#4507).
89

910
import { describe, it, expect, beforeAll, afterAll } from "vitest";
1011
import { createRequire } from "node:module";
@@ -72,18 +73,35 @@ describe("sequentialthinking: initialize and tools/list", () => {
7273
expect(tool.execution).toBeUndefined();
7374
});
7475

75-
// #799: some clients cap a tool description at 1024 characters. This one is
76-
// 2781 today; asserting <= 1024 would fail, so the current length is pinned.
77-
it("has a 2781-character description today (#799)", () => {
78-
expect(tool.description).toHaveLength(2781);
76+
// #799: OpenAI and Azure OpenAI reject a tool description over 1024
77+
// characters. The MCP spec sets no cap; this keeps the tool usable there.
78+
it("keeps the description within 1024 characters (#799)", () => {
79+
expect(tool.description).toBeDefined();
80+
expect(tool.description?.length ?? 0).toBeLessThanOrEqual(1024);
7981
expect(tool.description).toMatch(
8082
/^A detailed tool for dynamic and reflective problem-solving through thoughts\.\n/,
8183
);
84+
expect(tool.description).toContain("When to use this tool:");
8285
expect(tool.description).toMatch(
83-
/11\. Only set nextThoughtNeeded to false when truly done and a satisfactory answer is reached$/,
86+
/Set nextThoughtNeeded to false only when truly done and a satisfactory answer is reached$/,
8487
);
8588
});
8689

90+
// #4507: the parameters are explained by the input schema, not the
91+
// description, so every property must carry a description of its own, and
92+
// the description no longer restates them in a "Parameters explained" list.
93+
it("leaves explaining each parameter to the input schema (#4507)", () => {
94+
const properties = tool.inputSchema.properties ?? {};
95+
expect(Object.keys(properties)).toHaveLength(9);
96+
for (const [name, schema] of Object.entries(properties)) {
97+
expect(
98+
(schema as { description?: unknown }).description,
99+
`inputSchema property ${name}`,
100+
).toEqual(expect.any(String));
101+
}
102+
expect(tool.description).not.toMatch(/Parameters explained|Key features/);
103+
});
104+
87105
it("advertises the input schema as JSON Schema 2020-12", () => {
88106
expect(tool.inputSchema).toEqual({
89107
$schema: "https://json-schema.org/draft/2020-12/schema",

‎src/sequentialthinking/index.ts‎

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,60 +54,27 @@ export function createServer(): McpServer {
5454
"sequentialthinking",
5555
{
5656
title: "Sequential Thinking",
57+
// At most 1024 characters, the cap OpenAI and Azure OpenAI put on a tool
58+
// description (#799). Each parameter is explained by its own inputSchema
59+
// description, which clients send too, so this text carries only when to
60+
// call the tool and the guidance those field descriptions do not (#4507).
5761
description: `A detailed tool for dynamic and reflective problem-solving through thoughts.
58-
This tool helps analyze problems through a flexible thinking process that can adapt and evolve.
5962
Each thought can build on, question, or revise previous insights as understanding deepens.
6063
6164
When to use this tool:
6265
- Breaking down complex problems into steps
6366
- Planning and design with room for revision
6467
- Analysis that might need course correction
6568
- Problems where the full scope might not be clear initially
66-
- Problems that require a multi-step solution
6769
- Tasks that need to maintain context over multiple steps
6870
- Situations where irrelevant information needs to be filtered out
6971
70-
Key features:
71-
- You can adjust total_thoughts up or down as you progress
72-
- You can question or revise previous thoughts
73-
- You can add more thoughts even after reaching what seemed like the end
74-
- You can express uncertainty and explore alternative approaches
75-
- Not every thought needs to build linearly - you can branch or backtrack
76-
- Generates a solution hypothesis
77-
- Verifies the hypothesis based on the Chain of Thought steps
78-
- Repeats the process until satisfied
79-
- Provides a correct answer
80-
81-
Parameters explained:
82-
- thought: Your current thinking step, which can include:
83-
* Regular analytical steps
84-
* Revisions of previous thoughts
85-
* Questions about previous decisions
86-
* Realizations about needing more analysis
87-
* Changes in approach
88-
* Hypothesis generation
89-
* Hypothesis verification
90-
- nextThoughtNeeded: True if you need more thinking, even if at what seemed like the end
91-
- thoughtNumber: Current number in sequence (can go beyond initial total if needed)
92-
- totalThoughts: Current estimate of thoughts needed (can be adjusted up/down)
93-
- isRevision: A boolean indicating if this thought revises previous thinking
94-
- revisesThought: If is_revision is true, which thought number is being reconsidered
95-
- branchFromThought: If branching, which thought number is the branching point
96-
- branchId: Identifier for the current branch (if any)
97-
- needsMoreThoughts: If reaching end but realizing more thoughts needed
98-
9972
You should:
100-
1. Start with an initial estimate of needed thoughts, but be ready to adjust
101-
2. Feel free to question or revise previous thoughts
102-
3. Don't hesitate to add more thoughts if needed, even at the "end"
103-
4. Express uncertainty when present
104-
5. Mark thoughts that revise previous thinking or branch into new paths
105-
6. Ignore information that is irrelevant to the current step
106-
7. Generate a solution hypothesis when appropriate
107-
8. Verify the hypothesis based on the Chain of Thought steps
108-
9. Repeat the process until satisfied with the solution
109-
10. Provide a single, ideally correct answer as the final output
110-
11. Only set nextThoughtNeeded to false when truly done and a satisfactory answer is reached`,
73+
1. Estimate totalThoughts up front and adjust it up or down as you go; thoughtNumber may exceed it
74+
2. Question or revise earlier thoughts (isRevision with revisesThought), or branch (branchFromThought with branchId)
75+
3. Express uncertainty, and ignore information irrelevant to the current step
76+
4. Generate a solution hypothesis, verify it against the earlier steps, and repeat until satisfied
77+
5. Set nextThoughtNeeded to false only when truly done and a satisfactory answer is reached`,
11178
inputSchema: z.object({
11279
thought: z.string().describe("Your current thinking step"),
11380
nextThoughtNeeded: coercedBoolean.describe(

0 commit comments

Comments
 (0)