small fixes like argsSchema
This commit is contained in:
parent
d1c94a2c69
commit
bce2dbfb83
2 changed files with 51 additions and 55 deletions
|
|
@ -1011,7 +1011,7 @@ export class McpServer {
|
|||
config: {
|
||||
title?: string;
|
||||
description?: string;
|
||||
arguments?: Args;
|
||||
argsSchema?: Args;
|
||||
},
|
||||
cb: PromptCallback<Args>
|
||||
): RegisteredPrompt {
|
||||
|
|
@ -1019,7 +1019,7 @@ export class McpServer {
|
|||
throw new Error(`Prompt ${name} is already registered`);
|
||||
}
|
||||
|
||||
const { title, description, arguments: argsSchema } = config;
|
||||
const { title, description, argsSchema } = config;
|
||||
|
||||
const registeredPrompt = this._createRegisteredPrompt(
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import { McpServer } from "./mcp.js";
|
|||
describe("Title field backwards compatibility", () => {
|
||||
it("should work with tools that have title", async () => {
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
const server = new McpServer(
|
||||
{ name: "test-server", version: "1.0.0" },
|
||||
{ capabilities: {} }
|
||||
);
|
||||
|
||||
|
||||
// Register tool with title
|
||||
server.registerTool(
|
||||
"test-tool",
|
||||
|
|
@ -25,12 +25,12 @@ describe("Title field backwards compatibility", () => {
|
|||
},
|
||||
async () => ({ content: [{ type: "text", text: "result" }] })
|
||||
);
|
||||
|
||||
|
||||
const client = new Client({ name: "test-client", version: "1.0.0" });
|
||||
|
||||
|
||||
await server.server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
|
||||
const tools = await client.listTools();
|
||||
expect(tools.tools).toHaveLength(1);
|
||||
expect(tools.tools[0].name).toBe("test-tool");
|
||||
|
|
@ -40,12 +40,12 @@ describe("Title field backwards compatibility", () => {
|
|||
|
||||
it("should work with tools without title", async () => {
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
const server = new McpServer(
|
||||
{ name: "test-server", version: "1.0.0" },
|
||||
{ capabilities: {} }
|
||||
);
|
||||
|
||||
|
||||
// Register tool without title
|
||||
server.tool(
|
||||
"test-tool",
|
||||
|
|
@ -53,12 +53,12 @@ describe("Title field backwards compatibility", () => {
|
|||
{ value: z.string() },
|
||||
async () => ({ content: [{ type: "text", text: "result" }] })
|
||||
);
|
||||
|
||||
|
||||
const client = new Client({ name: "test-client", version: "1.0.0" });
|
||||
|
||||
|
||||
await server.server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
|
||||
const tools = await client.listTools();
|
||||
expect(tools.tools).toHaveLength(1);
|
||||
expect(tools.tools[0].name).toBe("test-tool");
|
||||
|
|
@ -68,12 +68,12 @@ describe("Title field backwards compatibility", () => {
|
|||
|
||||
it("should work with prompts that have title using update", async () => {
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
const server = new McpServer(
|
||||
{ name: "test-server", version: "1.0.0" },
|
||||
{ capabilities: {} }
|
||||
);
|
||||
|
||||
|
||||
// Register prompt with title by updating after creation
|
||||
const prompt = server.prompt(
|
||||
"test-prompt",
|
||||
|
|
@ -81,12 +81,12 @@ describe("Title field backwards compatibility", () => {
|
|||
async () => ({ messages: [{ role: "user", content: { type: "text", text: "test" } }] })
|
||||
);
|
||||
prompt.update({ title: "Test Prompt Display Name" });
|
||||
|
||||
|
||||
const client = new Client({ name: "test-client", version: "1.0.0" });
|
||||
|
||||
|
||||
await server.server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
|
||||
const prompts = await client.listPrompts();
|
||||
expect(prompts.prompts).toHaveLength(1);
|
||||
expect(prompts.prompts[0].name).toBe("test-prompt");
|
||||
|
|
@ -96,33 +96,33 @@ describe("Title field backwards compatibility", () => {
|
|||
|
||||
it("should work with prompts using registerPrompt", async () => {
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
const server = new McpServer(
|
||||
{ name: "test-server", version: "1.0.0" },
|
||||
{ capabilities: {} }
|
||||
);
|
||||
|
||||
|
||||
// Register prompt with title using registerPrompt
|
||||
server.registerPrompt(
|
||||
"test-prompt",
|
||||
{
|
||||
title: "Test Prompt Display Name",
|
||||
description: "A test prompt",
|
||||
arguments: { input: z.string() }
|
||||
argsSchema: { input: z.string() }
|
||||
},
|
||||
async ({ input }) => ({
|
||||
messages: [{
|
||||
role: "user",
|
||||
content: { type: "text", text: `test: ${input}` }
|
||||
}]
|
||||
async ({ input }) => ({
|
||||
messages: [{
|
||||
role: "user",
|
||||
content: { type: "text", text: `test: ${input}` }
|
||||
}]
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
const client = new Client({ name: "test-client", version: "1.0.0" });
|
||||
|
||||
|
||||
await server.server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
|
||||
const prompts = await client.listPrompts();
|
||||
expect(prompts.prompts).toHaveLength(1);
|
||||
expect(prompts.prompts[0].name).toBe("test-prompt");
|
||||
|
|
@ -133,12 +133,12 @@ describe("Title field backwards compatibility", () => {
|
|||
|
||||
it("should work with resources using registerResource", async () => {
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
const server = new McpServer(
|
||||
{ name: "test-server", version: "1.0.0" },
|
||||
{ capabilities: {} }
|
||||
);
|
||||
|
||||
|
||||
// Register resource with title using registerResource
|
||||
server.registerResource(
|
||||
"test-resource",
|
||||
|
|
@ -148,19 +148,19 @@ describe("Title field backwards compatibility", () => {
|
|||
description: "A test resource",
|
||||
mimeType: "text/plain"
|
||||
},
|
||||
async () => ({
|
||||
contents: [{
|
||||
async () => ({
|
||||
contents: [{
|
||||
uri: "https://example.com/test",
|
||||
text: "test content"
|
||||
}]
|
||||
text: "test content"
|
||||
}]
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
const client = new Client({ name: "test-client", version: "1.0.0" });
|
||||
|
||||
|
||||
await server.server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
|
||||
const resources = await client.listResources();
|
||||
expect(resources.resources).toHaveLength(1);
|
||||
expect(resources.resources[0].name).toBe("test-resource");
|
||||
|
|
@ -171,21 +171,21 @@ describe("Title field backwards compatibility", () => {
|
|||
|
||||
it("should support serverInfo with title", async () => {
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
const server = new Server(
|
||||
{
|
||||
{
|
||||
name: "test-server",
|
||||
version: "1.0.0",
|
||||
title: "Test Server Display Name"
|
||||
},
|
||||
{ capabilities: {} }
|
||||
);
|
||||
|
||||
|
||||
const client = new Client({ name: "test-client", version: "1.0.0" });
|
||||
|
||||
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
|
||||
const serverInfo = client.getServerVersion();
|
||||
expect(serverInfo?.name).toBe("test-server");
|
||||
expect(serverInfo?.version).toBe("1.0.0");
|
||||
|
|
|
|||
Loading…
Reference in a new issue