Skip to content

Commit a7b7ae2

Browse files
committed
chore: cleanup
1 parent c78a6f1 commit a7b7ae2

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ const config = {
115115
systemPrompt: getPrompt("system.md"),
116116
mcpServers: {
117117
someMcpServer: {
118+
description:
119+
"A detailed description of the MCP server and its capabilities used to provide hints to inference agent",
118120
command: "bunx",
119121
args: ["..."],
120122
prompt: getPrompt("someMcpServer.md"),
@@ -123,6 +125,8 @@ const config = {
123125
}
124126
```
125127

128+
The `description` field is **critical**; it's used by the inference routing agent to determine when to invoke the server or subagent.
129+
126130
#### Remote Prompts
127131

128132
Prompts can be loaded from remote sources (e.g., APIs) using `getRemotePrompt`. This enables dynamic prompt management where prompts are stored in a database or CMS rather than in files.
@@ -236,8 +240,6 @@ When a user asks something like "Analyze partner churn", the routing agent will:
236240
2. Automatically connect to the required `salesforce` MCP server
237241
3. Invoke the subagent with its specialized prompt and tools
238242

239-
The `description` field is **critical**; it's used by the routing agent to determine when to invoke the subagent.
240-
241243
**Note:** Subagents also support remote prompts via `getRemotePrompt`, allowing you to manage agent prompts dynamically from an API or database.
242244

243245
### Note on Lazy MCP Server Initialization

src/mcp/getMcpServer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { z } from "zod"
55

66
export const getMcpServer = () => {
77
// Store Claude Agent SDK sessionId per-instance (not shared across threads)
8-
let claudeSessionId: string | undefined
8+
let sessionId: string | undefined
99

1010
// Map thread IDs to Claude Agent SDK session IDs for per-thread isolation
1111
const threadSessions = new Map<string, string>()
@@ -35,23 +35,23 @@ export const getMcpServer = () => {
3535
},
3636
},
3737
async ({ query }) => {
38-
const existingConnectedServers = claudeSessionId
39-
? sessionConnectedServers.get(claudeSessionId)
38+
const existingConnectedServers = sessionId
39+
? sessionConnectedServers.get(sessionId)
4040
: undefined
4141

4242
const { response, connectedServers } = await runStandaloneAgentLoop({
4343
prompt: query,
4444
mcpServer,
45-
sessionId: claudeSessionId,
45+
sessionId,
4646
existingConnectedServers,
4747
onSessionIdReceived: (newSessionId) => {
48-
claudeSessionId = newSessionId
48+
sessionId = newSessionId
4949
},
5050
})
5151

5252
// Update the session's connected servers
53-
if (claudeSessionId) {
54-
sessionConnectedServers.set(claudeSessionId, connectedServers)
53+
if (sessionId) {
54+
sessionConnectedServers.set(sessionId, connectedServers)
5555
}
5656

5757
return {

src/store.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ export interface ToolDenied {
4141
export type ChatHistoryEntry = Message | ToolUse | ToolDenied
4242

4343
type McpServerConfigWithPrompt = McpServerConfig & {
44+
/** A detailed description of the MCP server that the inference agent evaluates */
4445
description: string
45-
prompt?: () => Promise<string>
4646
disallowedTools?: string[]
4747
enabled?: boolean
48+
prompt?: () => Promise<string>
4849
}
4950

5051
export interface AgentChatConfig {
5152
agents?: Record<string, AgentConfig>
52-
disallowedTools?: string[]
5353
connectionTimeout?: number
54+
disallowedTools?: string[]
5455
maxRetries?: number
5556
mcpServers: Record<string, McpServerConfigWithPrompt>
5657
model?: "sonnet" | "haiku"
@@ -61,8 +62,8 @@ export interface AgentChatConfig {
6162
}
6263

6364
export interface PendingToolPermission {
64-
toolName: string
6565
input: any
66+
toolName: string
6667
}
6768

6869
export interface StoreModel {
@@ -80,9 +81,9 @@ export interface StoreModel {
8081
stats?: string | null
8182

8283
// Computed
83-
isBooted: Computed<StoreModel, boolean>
84-
availableMcpServers: Computed<StoreModel, string[]>
8584
availableAgents: Computed<StoreModel, string[]>
85+
availableMcpServers: Computed<StoreModel, string[]>
86+
isBooted: Computed<StoreModel, boolean>
8687

8788
// Actions
8889
abortRequest: Action<StoreModel>
@@ -91,6 +92,7 @@ export interface StoreModel {
9192
appendCurrentAssistantMessage: Action<StoreModel, string>
9293
clearCurrentAssistantMessage: Action<StoreModel>
9394
clearToolUses: Action<StoreModel>
95+
handleMcpServerStatus: Thunk<StoreModel, McpServerStatus[]>
9496
reset: Action<StoreModel>
9597
sendMessage: Action<StoreModel, string>
9698
setPendingToolPermission: Action<
@@ -106,22 +108,21 @@ export interface StoreModel {
106108
setMcpServers: Action<StoreModel, McpServerStatus[]>
107109
setSessionId: Action<StoreModel, string>
108110
setStats: Action<StoreModel, string | null>
109-
handleMcpServerStatus: Thunk<StoreModel, McpServerStatus[]>
110111
}
111112

112113
export const AgentStore = createContextStore<StoreModel>({
113114
abortController: new AbortController(),
114115
chatHistory: [],
115-
messageQueue: new MessageQueue(),
116-
sessionId: undefined,
117-
mcpServers: [],
118-
input: "",
119-
isProcessing: false,
116+
config: null as unknown as AgentChatConfig,
120117
currentAssistantMessage: "",
121118
currentToolUses: [],
119+
input: "",
120+
isProcessing: false,
121+
mcpServers: [],
122+
messageQueue: new MessageQueue(),
122123
pendingToolPermission: undefined,
124+
sessionId: undefined,
123125
stats: undefined,
124-
config: null as unknown as AgentChatConfig,
125126

126127
// Computed
127128
isBooted: computed((state) => {

0 commit comments

Comments
 (0)