Skip to content

Commit

Permalink
fix: resource tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Pilar <[email protected]>
  • Loading branch information
pilartomas committed Jan 7, 2025
1 parent 6b57f6b commit 6fb846c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
51 changes: 25 additions & 26 deletions src/tools/mcp/mcpResource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,22 @@ const resources = {
} as const;

describe("MCPResourceTool", () => {
const server = new Server(
{
name: "test-server",
version: "1.0.0",
},
{
capabilities: {
resources: {},
},
},
);

const client = new Client(
{
name: "test-client",
version: "1.0.0",
},
{
capabilities: {},
},
);

let server: Server;
let client: Client;
let instance: MCPResourceTool;

beforeAll(async () => {
beforeEach(async () => {
server = new Server(
{
name: "test-server",
version: "1.0.0",
},
{
capabilities: {
resources: {},
},
},
);
server.setRequestHandler(ListResourcesRequestSchema, async () => {
return {
resources: entries(resources).map(([uri, { name }]) => ({ uri, name })),
Expand All @@ -84,12 +75,20 @@ describe("MCPResourceTool", () => {
};
});

client = new Client(
{
name: "test-client",
version: "1.0.0",
},
{
capabilities: {},
},
);

const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
await client.connect(clientTransport);
});

beforeEach(() => {
instance = new MCPResourceTool({ client });
});

Expand All @@ -101,7 +100,7 @@ describe("MCPResourceTool", () => {
});
});

afterAll(async () => {
afterEach(async () => {
await client.close();
await server.close();
});
Expand Down
2 changes: 1 addition & 1 deletion src/tools/mcp/mcpResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface MCPResourceToolInput extends MCPToolInput {

export class MCPResourceTool extends MCPTool<ReadResourceResult> {
name = "MCPResource";
description = `The Resource tool provides the ability to read external resources. Use it to read contents of available resources listed below.`;
description = `The MCPResource tool provides the ability to read external resources. Use it to read contents of available resources.`;

public readonly emitter: ToolEmitter<ToolInput<this>, MCPToolOutput<ReadResourceResult>> =
Emitter.root.child({
Expand Down

0 comments on commit 6fb846c

Please sign in to comment.