mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 21:54:05 +02:00
Refactor-renamed long-running-operation.ts to trigger-long-running-operation.ts
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
- `get-structured-content` (tools/get-structured-content.ts): Demonstrates structured responses. Accepts `location` input and returns both backward‑compatible `content` (a `text` block containing JSON) and `structuredContent` validated by an `outputSchema` (temperature, conditions, humidity).
|
||||
- `get-sum` (tools/get-sum.ts): For two numbers `a` and `b` calculates and returns their sum. Uses Zod to validate inputs.
|
||||
- `get-tiny-image` (tools/get-tiny-image.ts): Returns a tiny PNG MCP logo as an `image` content item with brief descriptive text before and after.
|
||||
- `long-running-operation` (tools/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.
|
||||
- `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.
|
||||
- `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.
|
||||
- `toggle-subscriber-updates` (tools/toggle-subscriber-updates.ts): Starts or stops simulated resource update notifications for URIs the invoking session has subscribed to.
|
||||
- `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.
|
||||
|
||||
@@ -47,10 +47,10 @@ src/everything
|
||||
│ ├── get-sum.ts
|
||||
│ ├── get-tiny-image.ts
|
||||
│ ├── gzip-file-as-resource.ts
|
||||
│ ├── long-running-operation.ts
|
||||
│ ├── toggle-simulated-logging.ts
|
||||
│ ├── toggle-subscriber-updates.ts
|
||||
│ ├── trigger-elicitation-request.ts
|
||||
│ ├── trigger-long-running-operation.ts
|
||||
│ └── trigger-sampling-request.ts
|
||||
└── transports
|
||||
├── sse.ts
|
||||
@@ -156,7 +156,7 @@ src/everything
|
||||
- Registers an `get-sum` tool with a Zod input schema that sums two numbers `a` and `b` and returns the result.
|
||||
- `get-tiny-image.ts`
|
||||
- Registers a `get-tiny-image` tool, which returns a tiny PNG MCP logo as an `image` content item, along with surrounding descriptive `text` items.
|
||||
- `long-running-operation.ts`
|
||||
- `trigger-long-running-operation.ts`
|
||||
- Registers a `long-running-operation` tool that simulates a long-running task over a specified `duration` (seconds) and number of `steps`; emits `notifications/progress` updates when the client supplies a `progressToken`.
|
||||
- `toggle-simulated-logging.ts`
|
||||
- Registers a `toggle-simulated-logging` tool, which starts or stops simulated logging for the invoking session.
|
||||
|
||||
@@ -9,10 +9,10 @@ import { registerGetStructuredContentTool } from "./get-structured-content.js";
|
||||
import { registerGetSumTool } from "./get-sum.js";
|
||||
import { registerGetTinyImageTool } from "./get-tiny-image.js";
|
||||
import { registerGZipFileAsResourceTool } from "./gzip-file-as-resource.js";
|
||||
import { registerLongRunningOperationTool } from "./long-running-operation.js";
|
||||
import { registerToggleSimulatedLoggingTool } from "./toggle-simulated-logging.js";
|
||||
import { registerToggleSubscriberUpdatesTool } from "./toggle-subscriber-updates.js";
|
||||
import { registerTriggerElicitationRequestTool } from "./trigger-elicitation-request.js";
|
||||
import { registerTriggerLongRunningOperationTool } from "./trigger-long-running-operation.js";
|
||||
import { registerTriggerSamplingRequestTool } from "./trigger-sampling-request.js";
|
||||
|
||||
/**
|
||||
@@ -30,9 +30,9 @@ export const registerTools = (server: McpServer) => {
|
||||
registerGetSumTool(server);
|
||||
registerGetTinyImageTool(server);
|
||||
registerGZipFileAsResourceTool(server);
|
||||
registerLongRunningOperationTool(server);
|
||||
registerToggleSimulatedLoggingTool(server);
|
||||
registerToggleSubscriberUpdatesTool(server);
|
||||
registerTriggerElicitationRequestTool(server);
|
||||
registerTriggerLongRunningOperationTool(server);
|
||||
registerTriggerSamplingRequestTool(server);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
||||
|
||||
// Tool input schema
|
||||
const LongRunningOperationSchema = z.object({
|
||||
const TriggerLongRunningOperationSchema = z.object({
|
||||
duration: z
|
||||
.number()
|
||||
.default(10)
|
||||
@@ -12,15 +12,15 @@ const LongRunningOperationSchema = z.object({
|
||||
});
|
||||
|
||||
// Tool configuration
|
||||
const name = "long-running-operation";
|
||||
const name = "trigger-long-running-operation";
|
||||
const config = {
|
||||
title: "Long Running Operation Tool",
|
||||
description: "Demonstrates a long running operation with progress updates",
|
||||
inputSchema: LongRunningOperationSchema,
|
||||
title: "Trigger Long Running Operation Tool",
|
||||
description: "Demonstrates a long running operation with progress updates.",
|
||||
inputSchema: TriggerLongRunningOperationSchema,
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers the 'long-running-operation' tool with the provided McpServer instance.
|
||||
* Registers the 'trigger-tong-running-operation' tool with the provided McpServer instance.
|
||||
*
|
||||
* This function defines and registers a tool with the provided server instance that performs a
|
||||
* long-running operation defined by a specific duration and number of steps. The progress
|
||||
@@ -35,12 +35,12 @@ const config = {
|
||||
* @param {McpServer} server - The server instance where the tool should be registered.
|
||||
* The server is responsible for receiving and handling requests, as well as sending progress notifications.
|
||||
*/
|
||||
export const registerLongRunningOperationTool = (server: McpServer) => {
|
||||
export const registerTriggerLongRunningOperationTool = (server: McpServer) => {
|
||||
server.registerTool(
|
||||
name,
|
||||
config,
|
||||
async (args, extra): Promise<CallToolResult> => {
|
||||
const validatedArgs = LongRunningOperationSchema.parse(args);
|
||||
const validatedArgs = TriggerLongRunningOperationSchema.parse(args);
|
||||
const { duration, steps } = validatedArgs;
|
||||
const stepDuration = duration / steps;
|
||||
const progressToken = extra._meta?.progressToken;
|
||||
Reference in New Issue
Block a user