test: add MCP call tests for each search tool

This commit is contained in:
Sampson committed 2026-08-11 13:24:52 -05:00
1 parent 38d703263d
commit 896ac6acd3
8 files changed
+361

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { connectTestClient, stubFetch } from '../../testUtils/mcpTestHarness.js';
import { name } from './index.js';
describe(name, () => {
let client: Client;
let close: () => Promise<void>;
let restoreFetch: () => void;
before(async () => {
restoreFetch = stubFetch((url) => {
if (url.pathname === '/res/v1/llm/context') {
return {
grounding: {
generic: [
{
url: 'https://search.brave.com/',
title: 'Brave Search',
snippets: ['Brave is a privacy-focused browser and search engine.'],
},
],
map: [],
},
sources: {
'https://search.brave.com/': { title: 'Brave Search' },
},
};
}
});
({ client, close } = await connectTestClient());
});
after(async () => {
restoreFetch();
await close();
});
it('returns grounding content for a simple query', async () => {
const result = await client.callTool({ name, arguments: { query: 'brave browser' } });
assert.equal(result.isError ?? false, false, JSON.stringify(result.content));
assert.ok(Array.isArray(result.content) && result.content.length > 0);
});
});