chore: refactor tests (#61)

This commit is contained in:
Simon Knott
2025-03-27 23:47:15 +01:00
committed by GitHub
parent 5e200405e5
commit b477b7c26f
2 changed files with 145 additions and 405 deletions

View File

@@ -108,6 +108,49 @@ class MCPServer extends EventEmitter {
this._child.stdin?.end();
});
}
async listTools() {
const list = await this.send({
jsonrpc: '2.0',
id: 0,
method: 'tools/list',
});
return list.result.tools;
}
async listResources() {
const list = await this.send({
jsonrpc: '2.0',
id: 0,
method: 'resources/list',
});
return list.result.resources;
}
async callTool(name: string, args?: any) {
const result = await this.send({
jsonrpc: '2.0',
id: 0,
method: 'tools/call',
params: {
name,
arguments: args,
}
});
return result.result.content.map(c => c.text);
}
async readResource(uri: string) {
const result = await this.send({
jsonrpc: '2.0',
id: 0,
method: 'resources/read',
params: {
uri,
},
});
return result.result.contents;
}
}
type Fixtures = {