Skip to content

Commit 0576c9a

Browse files
authored
Merge branch 'main' into fix/ssl-verification-508
2 parents dc626ba + 549dd02 commit 0576c9a

14 files changed

Lines changed: 992 additions & 41 deletions

.github/workflows/claude.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
actions: read
2727
steps:
2828
- name: Checkout repository
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v6
3030
with:
3131
fetch-depth: 1
3232

.github/workflows/python.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
outputs:
1515
packages: ${{ steps.find-packages.outputs.packages }}
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818

1919
- name: Find Python packages
2020
id: find-packages
@@ -31,13 +31,13 @@ jobs:
3131
name: Test ${{ matrix.package }}
3232
runs-on: ubuntu-latest
3333
steps:
34-
- uses: actions/checkout@v4
34+
- uses: actions/checkout@v6
3535

3636
- name: Install uv
3737
uses: astral-sh/setup-uv@v3
3838

3939
- name: Set up Python
40-
uses: actions/setup-python@v5
40+
uses: actions/setup-python@v6
4141
with:
4242
python-version-file: "src/${{ matrix.package }}/.python-version"
4343

@@ -68,13 +68,13 @@ jobs:
6868
name: Build ${{ matrix.package }}
6969
runs-on: ubuntu-latest
7070
steps:
71-
- uses: actions/checkout@v4
71+
- uses: actions/checkout@v6
7272

7373
- name: Install uv
7474
uses: astral-sh/setup-uv@v3
7575

7676
- name: Set up Python
77-
uses: actions/setup-python@v5
77+
uses: actions/setup-python@v6
7878
with:
7979
python-version-file: "src/${{ matrix.package }}/.python-version"
8080

@@ -91,7 +91,7 @@ jobs:
9191
run: uv build
9292

9393
- name: Upload artifacts
94-
uses: actions/upload-artifact@v4
94+
uses: actions/upload-artifact@v6
9595
with:
9696
name: dist-${{ matrix.package }}
9797
path: src/${{ matrix.package }}/dist/
@@ -112,7 +112,7 @@ jobs:
112112

113113
steps:
114114
- name: Download artifacts
115-
uses: actions/download-artifact@v4
115+
uses: actions/download-artifact@v7
116116
with:
117117
name: dist-${{ matrix.package }}
118118
path: dist/

.github/workflows/readme-pr-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
pull-requests: write
1818
steps:
1919
- name: Check files and comment if README-only
20-
uses: actions/github-script@v7
20+
uses: actions/github-script@v8
2121
with:
2222
script: |
2323
const { owner, repo } = context.repo;
@@ -63,7 +63,7 @@ jobs:
6363
pull-requests: write
6464
steps:
6565
- name: Swap labels and minimize comments
66-
uses: actions/github-script@v7
66+
uses: actions/github-script@v8
6767
with:
6868
script: |
6969
const { owner, repo } = context.repo;

.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
npm_packages: ${{ steps.create-npm-packages.outputs.npm_packages}}
1616
pypi_packages: ${{ steps.create-pypi-packages.outputs.pypi_packages}}
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v6
1919
with:
2020
fetch-depth: 0
2121

@@ -43,7 +43,7 @@ jobs:
4343
cat RELEASE_NOTES.md
4444
4545
- name: Release notes
46-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v6
4747
with:
4848
name: release-notes
4949
path: RELEASE_NOTES.md
@@ -74,7 +74,7 @@ jobs:
7474
outputs:
7575
changes_made: ${{ steps.commit.outputs.changes_made }}
7676
steps:
77-
- uses: actions/checkout@v4
77+
- uses: actions/checkout@v6
7878
with:
7979
fetch-depth: 0
8080

@@ -118,15 +118,15 @@ jobs:
118118
id-token: write # Required for trusted publishing
119119
runs-on: ubuntu-latest
120120
steps:
121-
- uses: actions/checkout@v4
121+
- uses: actions/checkout@v6
122122
with:
123123
ref: ${{ needs.create-metadata.outputs.version }}
124124

125125
- name: Install uv
126126
uses: astral-sh/setup-uv@v5
127127

128128
- name: Set up Python
129-
uses: actions/setup-python@v5
129+
uses: actions/setup-python@v6
130130
with:
131131
python-version-file: "src/${{ matrix.package }}/.python-version"
132132

@@ -158,11 +158,11 @@ jobs:
158158
environment: release
159159
runs-on: ubuntu-latest
160160
steps:
161-
- uses: actions/checkout@v4
161+
- uses: actions/checkout@v6
162162
with:
163163
ref: ${{ needs.create-metadata.outputs.version }}
164164

165-
- uses: actions/setup-node@v4
165+
- uses: actions/setup-node@v6
166166
with:
167167
node-version: 22
168168
cache: npm
@@ -204,10 +204,10 @@ jobs:
204204
permissions:
205205
contents: write
206206
steps:
207-
- uses: actions/checkout@v4
207+
- uses: actions/checkout@v6
208208

209209
- name: Download release notes
210-
uses: actions/download-artifact@v4
210+
uses: actions/download-artifact@v7
211211
with:
212212
name: release-notes
213213

.github/workflows/typescript.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
outputs:
1515
packages: ${{ steps.find-packages.outputs.packages }}
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818
- name: Find JS packages
1919
id: find-packages
2020
working-directory: src
@@ -30,9 +30,9 @@ jobs:
3030
name: Test ${{ matrix.package }}
3131
runs-on: ubuntu-latest
3232
steps:
33-
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v6
3434

35-
- uses: actions/setup-node@v4
35+
- uses: actions/setup-node@v6
3636
with:
3737
node-version: 22
3838
cache: npm
@@ -53,9 +53,9 @@ jobs:
5353
name: Build ${{ matrix.package }}
5454
runs-on: ubuntu-latest
5555
steps:
56-
- uses: actions/checkout@v4
56+
- uses: actions/checkout@v6
5757

58-
- uses: actions/setup-node@v4
58+
- uses: actions/setup-node@v6
5959
with:
6060
node-version: 22
6161
cache: npm
@@ -84,8 +84,8 @@ jobs:
8484
id-token: write
8585

8686
steps:
87-
- uses: actions/checkout@v4
88-
- uses: actions/setup-node@v4
87+
- uses: actions/checkout@v6
88+
- uses: actions/setup-node@v6
8989
with:
9090
node-version: 22
9191
cache: npm

src/everything/docs/features.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
- `trigger-long-running-operation` (tools/trigger-trigger-long-running-operation.ts): Simulates a multi-step operation over a given `duration` and number of `steps`; reports progress via `notifications/progress` when a `progressToken` is provided by the client.
2323
- `toggle-simulated-logging` (tools/toggle-simulated-logging.ts): Starts or stops simulated, random‑leveled logging for the invoking session. Respects the client’s selected minimum logging level.
2424
- `toggle-subscriber-updates` (tools/toggle-subscriber-updates.ts): Starts or stops simulated resource update notifications for URIs the invoking session has subscribed to.
25-
- `trigger-sampling-request` (tools/trigger-sampling-request.ts): Issues a `sampling/createMessage` request to the client/LLM using provided `prompt` and optional generation controls; returns the LLM’s response payload.
25+
- `trigger-sampling-request` (tools/trigger-sampling-request.ts): Issues a `sampling/createMessage` request to the client/LLM using provided `prompt` and optional generation controls; returns the LLM's response payload.
26+
- `simulate-research-query` (tools/simulate-research-query.ts): Demonstrates MCP Tasks (SEP-1686) with a simulated multi-stage research operation. Accepts `topic` and `ambiguous` parameters. Returns a task that progresses through stages with status updates. If `ambiguous` is true and client supports elicitation, sends an elicitation request directly to gather clarification before completing.
27+
- `trigger-sampling-request-async` (tools/trigger-sampling-request-async.ts): Demonstrates bidirectional tasks where the server sends a sampling request that the client executes as a background task. Server polls for status and retrieves the LLM result when complete. Requires client to support `tasks.requests.sampling.createMessage`.
28+
- `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts): Demonstrates bidirectional tasks where the server sends an elicitation request that the client executes as a background task. Server polls while waiting for user input. Requires client to support `tasks.requests.elicitation.create`.
2629

2730
## Prompts
2831

@@ -50,3 +53,51 @@
5053
- Simulated logging is available but off by default.
5154
- Use the `toggle-simulated-logging` tool to start/stop periodic log messages of varying levels (debug, info, notice, warning, error, critical, alert, emergency) per session.
5255
- Clients can control the minimum level they receive via the standard MCP `logging/setLevel` request.
56+
57+
## Tasks (SEP-1686)
58+
59+
The server advertises support for MCP Tasks, enabling long-running operations with status tracking:
60+
61+
- **Capabilities advertised**: `tasks.list`, `tasks.cancel`, `tasks.requests.tools.call`
62+
- **Task Store**: Uses `InMemoryTaskStore` from SDK experimental for task lifecycle management
63+
- **Message Queue**: Uses `InMemoryTaskMessageQueue` for task-related messaging
64+
65+
### Task Lifecycle
66+
67+
1. Client calls `tools/call` with `task: true` parameter
68+
2. Server returns `CreateTaskResult` with `taskId` instead of immediate result
69+
3. Client polls `tasks/get` to check status and receive `statusMessage` updates
70+
4. When status is `completed`, client calls `tasks/result` to retrieve the final result
71+
72+
### Task Statuses
73+
74+
- `working`: Task is actively processing
75+
- `input_required`: Task needs additional input (server sends elicitation request directly)
76+
- `completed`: Task finished successfully
77+
- `failed`: Task encountered an error
78+
- `cancelled`: Task was cancelled by client
79+
80+
### Demo Tools
81+
82+
**Server-side tasks (client calls server):**
83+
Use the `simulate-research-query` tool to exercise the full task lifecycle. Set `ambiguous: true` to trigger elicitation - the server will send an `elicitation/create` request directly and await the response before completing.
84+
85+
**Client-side tasks (server calls client):**
86+
Use `trigger-sampling-request-async` or `trigger-elicitation-request-async` to demonstrate bidirectional tasks where the server sends requests that the client executes as background tasks. These require the client to advertise `tasks.requests.sampling.createMessage` or `tasks.requests.elicitation.create` capabilities respectively.
87+
88+
### Bidirectional Task Flow
89+
90+
MCP Tasks are bidirectional - both server and client can be task executors:
91+
92+
| Direction | Request Type | Task Executor | Demo Tool |
93+
| ---------------- | ------------------------ | ------------- | ----------------------------------- |
94+
| Client -> Server | `tools/call` | Server | `simulate-research-query` |
95+
| Server -> Client | `sampling/createMessage` | Client | `trigger-sampling-request-async` |
96+
| Server -> Client | `elicitation/create` | Client | `trigger-elicitation-request-async` |
97+
98+
For client-side tasks:
99+
100+
1. Server sends request with task metadata (e.g., `params.task.ttl`)
101+
2. Client creates task and returns `CreateTaskResult` with `taskId`
102+
3. Server polls `tasks/get` for status updates
103+
4. When complete, server calls `tasks/result` to retrieve the result

src/everything/server/index.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2+
import {
3+
InMemoryTaskStore,
4+
InMemoryTaskMessageQueue,
5+
} from "@modelcontextprotocol/sdk/experimental/tasks";
26
import {
37
setSubscriptionHandlers,
48
stopSimulatedResourceUpdates,
@@ -32,6 +36,12 @@ export const createServer: () => ServerFactoryResponse = () => {
3236
// Read the server instructions
3337
const instructions = readInstructions();
3438

39+
// Create task store and message queue for task support
40+
const taskStore = new InMemoryTaskStore();
41+
const taskMessageQueue = new InMemoryTaskMessageQueue();
42+
43+
let initializeTimeout: NodeJS.Timeout | null = null;
44+
3545
// Create the server
3646
const server = new McpServer(
3747
{
@@ -52,8 +62,19 @@ export const createServer: () => ServerFactoryResponse = () => {
5262
listChanged: true,
5363
},
5464
logging: {},
65+
tasks: {
66+
list: {},
67+
cancel: {},
68+
requests: {
69+
tools: {
70+
call: {},
71+
},
72+
},
73+
},
5574
},
5675
instructions,
76+
taskStore,
77+
taskMessageQueue,
5778
}
5879
);
5980

@@ -79,7 +100,7 @@ export const createServer: () => ServerFactoryResponse = () => {
79100
// This is delayed until after the `notifications/initialized` handler finishes,
80101
// otherwise, the request gets lost.
81102
const sessionId = server.server.transport?.sessionId;
82-
setTimeout(() => syncRoots(server, sessionId), 350);
103+
initializeTimeout = setTimeout(() => syncRoots(server, sessionId), 350);
83104
};
84105

85106
// Return the ServerFactoryResponse
@@ -89,6 +110,9 @@ export const createServer: () => ServerFactoryResponse = () => {
89110
// Stop any simulated logging or resource updates that may have been initiated.
90111
stopSimulatedLogging(sessionId);
91112
stopSimulatedResourceUpdates(sessionId);
113+
// Clean up task store timers
114+
taskStore.cleanup();
115+
if (initializeTimeout) clearTimeout(initializeTimeout);
92116
},
93117
} satisfies ServerFactoryResponse;
94118
};

src/everything/server/roots.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,10 @@ export const syncRoots = async (server: McpServer, sessionId?: string) => {
6363
);
6464
}
6565
} catch (error) {
66-
await server.sendLoggingMessage(
67-
{
68-
level: "error",
69-
logger: "everything-server",
70-
data: `Failed to request roots from client: ${
71-
error instanceof Error ? error.message : String(error)
72-
}`,
73-
},
74-
sessionId
66+
console.error(
67+
`Failed to request roots from client ${sessionId}: ${
68+
error instanceof Error ? error.message : String(error)
69+
}`
7570
);
7671
}
7772
};

src/everything/tools/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { registerToggleSubscriberUpdatesTool } from "./toggle-subscriber-updates
1414
import { registerTriggerElicitationRequestTool } from "./trigger-elicitation-request.js";
1515
import { registerTriggerLongRunningOperationTool } from "./trigger-long-running-operation.js";
1616
import { registerTriggerSamplingRequestTool } from "./trigger-sampling-request.js";
17+
import { registerTriggerSamplingRequestAsyncTool } from "./trigger-sampling-request-async.js";
18+
import { registerTriggerElicitationRequestAsyncTool } from "./trigger-elicitation-request-async.js";
19+
import { registerSimulateResearchQueryTool } from "./simulate-research-query.js";
1720

1821
/**
1922
* Register the tools with the MCP server.
@@ -42,4 +45,9 @@ export const registerConditionalTools = (server: McpServer) => {
4245
registerGetRootsListTool(server);
4346
registerTriggerElicitationRequestTool(server);
4447
registerTriggerSamplingRequestTool(server);
48+
// Task-based research tool (uses experimental tasks API)
49+
registerSimulateResearchQueryTool(server);
50+
// Bidirectional task tools - server sends requests that client executes as tasks
51+
registerTriggerSamplingRequestAsyncTool(server);
52+
registerTriggerElicitationRequestAsyncTool(server);
4553
};

0 commit comments

Comments
 (0)