Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hooks/useAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function useAgent() {
actions.setIsProcessing(false)
}
},
[config, messageQueue, actions]
[config, mcpServers, messageQueue, actions]
)

// Start listening for new messages from input
Expand Down
2 changes: 1 addition & 1 deletion src/prompts/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You are a helpful Agent specifically designed to handle questions related to sys
## Core Rules

- **CRITICAL**: Only tools prefixed with `mcp_` are to be invoked. Any other tool such as "Bash", etc are strictly forbidden.

- **CRITICAL**: When a user attempts to user a tool or MCP server, understand that the first pass is an inference call. If the inference call fails, immediately review the system prompt to see if the tool or MCP server is allowed (ie, CONNECTED). If it is not connected, do not attempt to invoke the tool or MCP server.
- **CRITICAL**: When a user starts a convo and asks a question or assigns you a task (example: "in github, please summarize the last merged pr"), before beginning your task (ie, calling tools, etc) respond back immediately with a small summary about what you're going to do, in a friendly kind of way. Then start working.

- **CRITICAL**: If a user starts a convo with a general greeting (like "Hi!" or "Hello!") without a specific task request, treat it as a `/help` command, and inform them about some of the possibilities for interacting with Agent in a help-menu kind of way. Review your system prompt instructions to see what services are available.
Expand Down
5 changes: 3 additions & 2 deletions src/utils/__tests__/getPrompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ describe("buildSystemPrompt", () => {
config,
})

expect(prompt).not.toContain("Available MCP Servers")
expect(prompt).not.toContain("Unavailable MCP Servers")
expect(prompt).toContain("CRITICAL: MCP Server Connection Status Check")
expect(prompt).not.toContain("# Available MCP Servers")
expect(prompt).not.toContain("# Unavailable MCP Servers")
})

test("should handle empty inferred servers set", async () => {
Expand Down
12 changes: 12 additions & 0 deletions src/utils/getPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ export const buildSystemPrompt = async ({
parts.push(additionalSystemPrompt)
}

parts.push(`# CRITICAL: MCP Server Connection Status Check

**BEFORE responding to ANY request involving an inferred MCP server, you MUST:**

1. Check the "Unavailable MCP Servers" section
2. If the requested server is listed as FAILED/unavailable:
- IMMEDIATELY inform the user the server failed to connect in a friendly way
- State that NO tools are available for that server
- DO NOT offer functionality or ask how they'd like to use it
- STOP processing that request
`)

if (mcpServers.length > 0) {
// Add connection status sections first as these are the source of truth.
// Inference is secondary.
Expand Down