mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-25 12:01:03 +02:00
test(mcp): add mongo_query server registration test
Closes a coverage gap for the mongo_query MCP tool and fixes Knip's default-mode unused-export flag on KtxMongoQueryMcpPort, which had no cross-file consumer before this test imported it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BdUJSmjqGoksdc45ZZJiVY
This commit is contained in:
parent
5cfd64f151
commit
bba645852f
1 changed files with 52 additions and 0 deletions
|
|
@ -21,6 +21,8 @@ import type {
|
|||
KtxKnowledgeMcpPort,
|
||||
KtxMcpContextPorts,
|
||||
KtxMcpToolHandlerContext,
|
||||
KtxMongoQueryMcpPort,
|
||||
KtxMongoQueryResponse,
|
||||
KtxSemanticLayerMcpPort,
|
||||
KtxSqlExecutionMcpPort,
|
||||
KtxSqlExecutionResponse,
|
||||
|
|
@ -495,6 +497,56 @@ describe('createKtxMcpServer', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('registers mongo_query when the host provides a MongoDB query port', async () => {
|
||||
const fake = makeFakeServer();
|
||||
const response: KtxMongoQueryResponse = {
|
||||
headers: ['_id', 'city'],
|
||||
rows: [
|
||||
['a1', 'Indianapolis'],
|
||||
['a2', 'Indianapolis'],
|
||||
],
|
||||
rowCount: 2,
|
||||
};
|
||||
const mongoQuery: KtxMongoQueryMcpPort = {
|
||||
execute: vi.fn<KtxMongoQueryMcpPort['execute']>().mockResolvedValue(response),
|
||||
};
|
||||
|
||||
createKtxMcpServer({
|
||||
server: fake.server,
|
||||
userContext: { userId: 'local-user' },
|
||||
contextTools: {
|
||||
mongoQuery,
|
||||
},
|
||||
});
|
||||
|
||||
expect(fake.tools.map((tool) => tool.name)).toEqual(['mongo_query']);
|
||||
await expect(
|
||||
getTool(fake.tools, 'mongo_query').handler({
|
||||
connectionId: 'mongo',
|
||||
collection: 'business',
|
||||
pipeline: [{ $match: { city: 'Indianapolis' } }],
|
||||
limit: 100,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: JSON.stringify(response),
|
||||
},
|
||||
],
|
||||
structuredContent: response,
|
||||
});
|
||||
expect(mongoQuery.execute).toHaveBeenCalledWith(
|
||||
{
|
||||
connectionId: 'mongo',
|
||||
collection: 'business',
|
||||
pipeline: [{ $match: { city: 'Indianapolis' } }],
|
||||
limit: 100,
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it('registers entity_details when the host provides an entity-details port', async () => {
|
||||
const fake = makeFakeServer();
|
||||
const entityDetails: KtxEntityDetailsMcpPort = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue