[WIP] Refactor everything server to be more modular and use recommended APIs.

* Updated architecture.md

* Refactor/renamed get-sampling-request.ts to trigger-sampling-request.ts
  - use trigger instead of get throughout

* In tools/index.ts
  - sorted display order
This commit is contained in:
cliffhall
2025-12-11 17:39:25 -05:00
parent 2afc618ccd
commit 339e056ea0
3 changed files with 15 additions and 15 deletions

View File

@@ -4,7 +4,6 @@ import { registerEchoTool } from "./echo.js";
import { registerGetEnvTool } from "./get-env.js";
import { registerGetResourceLinksTool } from "./get-resource-links.js";
import { registerGetResourceReferenceTool } from "./get-resource-reference.js";
import { registerGetSamplingRequestTool } from "./get-sampling-request.js";
import { registerGetStructuredContentTool } from "./get-structured-content.js";
import { registerGetSumTool } from "./get-sum.js";
import { registerGetTinyImageTool } from "./get-tiny-image.js";
@@ -12,6 +11,7 @@ import { registerGZipFileAsResourceTool } from "./gzip-file-as-resource.js";
import { registerLongRunningOperationTool } from "./long-running-operation.js";
import { registerToggleLoggingTool } from "./toggle-logging.js";
import { registerToggleSubscriberUpdatesTool } from "./toggle-subscriber-updates.js";
import { registerTriggerSamplingRequestTool } from "./trigger-sampling-request.js";
/**
* Register the tools with the MCP server.
@@ -23,7 +23,6 @@ export const registerTools = (server: McpServer) => {
registerGetEnvTool(server);
registerGetResourceLinksTool(server);
registerGetResourceReferenceTool(server);
registerGetSamplingRequestTool(server);
registerGetStructuredContentTool(server);
registerGetSumTool(server);
registerGetTinyImageTool(server);
@@ -31,4 +30,5 @@ export const registerTools = (server: McpServer) => {
registerLongRunningOperationTool(server);
registerToggleLoggingTool(server);
registerToggleSubscriberUpdatesTool(server);
registerTriggerSamplingRequestTool(server);
};

View File

@@ -7,7 +7,7 @@ import {
import { z } from "zod";
// Tool input schema
const GetSamplingRequestSchema = z.object({
const TriggerSamplingRequestSchema = z.object({
prompt: z.string().describe("The prompt to send to the LLM"),
maxTokens: z
.number()
@@ -16,15 +16,15 @@ const GetSamplingRequestSchema = z.object({
});
// Tool configuration
const name = "get-sampling-request";
const name = "trigger-sampling-request";
const config = {
title: "Get Sampling Request Tool",
description: "Server Sends the Client a Request for LLM Sampling",
inputSchema: GetSamplingRequestSchema,
title: "Trigger Sampling Request Tool",
description: "Trigger a Request from the Server for LLM Sampling",
inputSchema: TriggerSamplingRequestSchema,
};
/**
* Registers the 'get-sampling-request' tool within the provided McpServer instance.
* Registers the 'trigger-sampling-request' tool within the provided McpServer instance.
*
* The registered tool performs the following operations:
* - Validates incoming arguments using `SampleLLMSchema`.
@@ -35,12 +35,12 @@ const config = {
* @param {McpServer} server - The instance of the MCP server where the tool
* will be registered.
*/
export const registerGetSamplingRequestTool = (server: McpServer) => {
export const registerTriggerSamplingRequestTool = (server: McpServer) => {
server.registerTool(
name,
config,
async (args, extra): Promise<CallToolResult> => {
const validatedArgs = GetSamplingRequestSchema.parse(args);
const validatedArgs = TriggerSamplingRequestSchema.parse(args);
const { prompt, maxTokens } = validatedArgs;
// Create the sampling request