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
64
+
65
+
**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.
66
+
52
67
### Usage
53
68
54
69
#### Interactive Agent Mode
@@ -80,11 +95,11 @@ Configure the MCP server connection in `mcp-client.config.ts`. HTTP is also supp
80
95
Run as a stand-alone MCP server, using one of two modes:
81
96
82
97
```bash
83
-
bun server
84
-
bun server:http
98
+
bun server:http # streaming HTTP (use this for deployments)
99
+
bun server# stdio
85
100
```
86
101
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.
102
+
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
103
89
104
### Configuration
90
105
@@ -96,31 +111,141 @@ To add specific instructions for each MCP server, create a markdown file in `src
96
111
97
112
```ts
98
113
const config = {
99
-
systemPrompt: "You are a helpful agent."
114
+
systemPrompt: getPrompt("system.md"),
100
115
mcpServers: {
101
116
someMcpServer: {
102
-
command: "npx",
117
+
command: "bunx",
103
118
args: ["..."],
104
119
prompt: getPrompt("someMcpServer.md"),
105
120
},
106
121
},
107
122
}
108
123
```
109
124
125
+
#### Remote Prompts
126
+
127
+
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.
128
+
129
+
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.
199
+
200
+
In CLI mode, if `permissionMode` is set to "ask" then a prompt will appear to confirm when tools need to be invoked.
201
+
202
+
### Specialized Subagents
203
+
204
+
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:
233
+
234
+
1. Match the query to the `sales-partner-sentiment-agent` based on its description
235
+
2. Automatically connect to the required `salesforce` MCP server
236
+
3. Invoke the subagent with its specialized prompt and tools
237
+
238
+
The `description` field is **critical**; it's used by the routing agent to determine when to invoke the subagent.
239
+
240
+
**Note:** Subagents also support remote prompts via `getRemotePrompt`, allowing you to manage agent prompts dynamically from an API or database.
241
+
242
+
### Note on Lazy MCP Server Initialization
243
+
244
+
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!
245
+
246
+
#### The Flow
247
+
248
+
- User sends a message, something like "In Salesforce, tell me about some recent leads"
249
+
- Sub-agent forwards message onto Anthropic's light-weight Haiku model and asks which MCP servers seem to be necessary
250
+
- Returns result as JSON, and based on the result, mcpServers are passed to the main agent query
251
+
- 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