You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bare-bones, terminal-based chat CLI built to explore the new [Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk/overview). Terminal rendering is built on top of [React Ink](https://github.com/vadimdemedes/ink).
3
+
A minimalist, terminal-based chat CLI built to explore the new [Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk/overview) and based on [damassi/agent-chat-cli](https://github.com/damassi/agent-chat-cli). Terminal rendering is built on top of [React Ink](https://github.com/vadimdemedes/ink).
4
+
5
+
Additionally, via inference, Agent Chat CLI supports lazy, turn-based MCP connections to keep token costs down. The agent will only use those MCP servers you ask about, limiting the context that is sent up to the LLM. (After an MCP server is connected it remains connected, however.)
6
+
7
+
## Overview
4
8
5
9
The app has three modes:
6
10
@@ -12,7 +16,7 @@ The agent, including MCP server setup, is configured in [agent-chat-cli.config.t
12
16
13
17
The MCP _client_ is configured in [mcp-client.config.ts](mcp-client.config.ts).
- Authenticate via OAuth, which will launch a browser when attempting to connect
65
+
66
+
**Note**: OAuth-based MCP servers (Notion, JIRA, etc) require browser-based authentication and cannot be deployed remotely. These servers are only accessible in the CLI version of the agent.
67
+
52
68
### Usage
53
69
54
70
#### Interactive Agent Mode
@@ -80,11 +96,11 @@ Configure the MCP server connection in `mcp-client.config.ts`. HTTP is also supp
80
96
Run as a stand-alone MCP server, using one of two modes:
81
97
82
98
```bash
83
-
bun server
84
-
bun server:http
99
+
bun server:http # streaming HTTP (use this for deployments)
100
+
bun server# stdio
85
101
```
86
102
87
-
The server exposes an `ask_agent`tool that other MCP clients can use to interact with the agent. The agent has access to all configured MCP servers and can use their tools.
103
+
The MCP server exposes an `ask_agent`and `ask_agent_slackbot` tools that other MCP clients can use to interact with the agent. The agent has access to all configured MCP servers and can use their tools.
88
104
89
105
### Configuration
90
106
@@ -96,31 +112,141 @@ To add specific instructions for each MCP server, create a markdown file in `src
96
112
97
113
```ts
98
114
const config = {
99
-
systemPrompt: "You are a helpful agent."
115
+
systemPrompt: getPrompt("system.md"),
100
116
mcpServers: {
101
117
someMcpServer: {
102
-
command: "npx",
118
+
command: "bunx",
103
119
args: ["..."],
104
120
prompt: getPrompt("someMcpServer.md"),
105
121
},
106
122
},
107
123
}
108
124
```
109
125
126
+
#### Remote Prompts
127
+
128
+
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.
129
+
130
+
Both `getPrompt` (for local files) and `getRemotePrompt` (for API calls) return lazy functions that are only evaluated when the agent needs them, ensuring prompts are fetched on-demand during each LLM turn, enabling iteration in real time.
Denied tools are filtered at the SDK level and won't be available to the agent.
200
+
201
+
In CLI mode, if `permissionMode` is set to "ask" then a prompt will appear to confirm when tools need to be invoked.
202
+
203
+
### Specialized Subagents
204
+
205
+
You can define specialized subagents in `agent-chat-cli.config.ts` to handle domain-specific tasks, leveraging the powerful [Claude Subagent SDK](https://docs.claude.com/en/docs/claude-code/sub-agents). Subagents are automatically invoked when user queries match their domain, and they have access to specific MCP servers.
When a user asks something like "Analyze partner churn", the routing agent will:
234
+
235
+
1. Match the query to the `sales-partner-sentiment-agent` based on its description
236
+
2. Automatically connect to the required `salesforce` MCP server
237
+
3. Invoke the subagent with its specialized prompt and tools
238
+
239
+
The `description` field is **critical**; it's used by the routing agent to determine when to invoke the subagent.
240
+
241
+
**Note:** Subagents also support remote prompts via `getRemotePrompt`, allowing you to manage agent prompts dynamically from an API or database.
242
+
243
+
### Note on Lazy MCP Server Initialization
244
+
245
+
In order to keep LLM costs low and response times quick, a specialized sub-agent sits in front of user queries to infer which MCP servers are needed; the result is then forwarded on to the main agent, lazily initializing required MCP servers. Without this, we would need to initialize _all_ MCP servers defined in the config upfront, and for every query that we send to Anthropic, we'd _also_ be sending along a huge system prompt, and this is very expensive!
246
+
247
+
#### The Flow
248
+
249
+
- User sends a message, something like "In Salesforce, tell me about some recent leads"
250
+
- Sub-agent forwards message onto Anthropic's light-weight Haiku model and asks which MCP servers seem to be necessary
251
+
- Returns result as JSON, and based on the result, mcpServers are passed to the main agent query
252
+
- Agent now boots quickly and responds in a timely way, vs having to wait for every MCP server to initialize before being able to chat
0 commit comments