feat: Open MCP docs if no MCPs are configured (#1325)
This commit is contained in:
parent
dc76bcc433
commit
fd58d3267e
|
@ -754,7 +754,8 @@ Add any other context about the problem here.
|
||||||
expect(commandResult).toBe(true);
|
expect(commandResult).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a message when no MCP servers are configured', async () => {
|
it('should display a message with a URL when no MCP servers are configured in a sandbox', async () => {
|
||||||
|
process.env.SANDBOX = 'sandbox';
|
||||||
mockConfig = {
|
mockConfig = {
|
||||||
...mockConfig,
|
...mockConfig,
|
||||||
getToolRegistry: vi.fn().mockResolvedValue({
|
getToolRegistry: vi.fn().mockResolvedValue({
|
||||||
|
@ -773,11 +774,39 @@ Add any other context about the problem here.
|
||||||
2,
|
2,
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: MessageType.INFO,
|
type: MessageType.INFO,
|
||||||
text: 'No MCP servers configured.',
|
text: `No MCP servers configured. Please open the following URL in your browser to view documentation:\nhttps://goo.gle/gemini-cli-docs-mcp`,
|
||||||
}),
|
}),
|
||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
);
|
);
|
||||||
expect(commandResult).toBe(true);
|
expect(commandResult).toBe(true);
|
||||||
|
delete process.env.SANDBOX;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display a message and open a URL when no MCP servers are configured outside a sandbox', async () => {
|
||||||
|
mockConfig = {
|
||||||
|
...mockConfig,
|
||||||
|
getToolRegistry: vi.fn().mockResolvedValue({
|
||||||
|
getToolsByServer: vi.fn().mockReturnValue([]),
|
||||||
|
}),
|
||||||
|
getMcpServers: vi.fn().mockReturnValue({}),
|
||||||
|
} as unknown as Config;
|
||||||
|
|
||||||
|
const { handleSlashCommand } = getProcessor();
|
||||||
|
let commandResult: SlashCommandActionReturn | boolean = false;
|
||||||
|
await act(async () => {
|
||||||
|
commandResult = await handleSlashCommand('/mcp');
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mockAddItem).toHaveBeenNthCalledWith(
|
||||||
|
2,
|
||||||
|
expect.objectContaining({
|
||||||
|
type: MessageType.INFO,
|
||||||
|
text: 'No MCP servers configured. Opening documentation in your browser: https://goo.gle/gemini-cli-docs-mcp',
|
||||||
|
}),
|
||||||
|
expect.any(Number),
|
||||||
|
);
|
||||||
|
expect(open).toHaveBeenCalledWith('https://goo.gle/gemini-cli-docs-mcp');
|
||||||
|
expect(commandResult).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display configured MCP servers with status indicators and their tools', async () => {
|
it('should display configured MCP servers with status indicators and their tools', async () => {
|
||||||
|
|
|
@ -291,11 +291,21 @@ export const useSlashCommandProcessor = (
|
||||||
const serverNames = Object.keys(mcpServers);
|
const serverNames = Object.keys(mcpServers);
|
||||||
|
|
||||||
if (serverNames.length === 0) {
|
if (serverNames.length === 0) {
|
||||||
addMessage({
|
const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
|
||||||
type: MessageType.INFO,
|
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
||||||
content: 'No MCP servers configured.',
|
addMessage({
|
||||||
timestamp: new Date(),
|
type: MessageType.INFO,
|
||||||
});
|
content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addMessage({
|
||||||
|
type: MessageType.INFO,
|
||||||
|
content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
|
||||||
|
timestamp: new Date(),
|
||||||
|
});
|
||||||
|
await open(docsUrl);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue