sweagent 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,6 +27,7 @@
27
27
  <a href="#domain-agent-modules">Modules</a> •
28
28
  <a href="#getting-started">Getting Started</a> •
29
29
  <a href="#installation">Installation</a> •
30
+ <a href="#mcp-server">MCP Server</a> •
30
31
  <a href="#architecture">Architecture</a> •
31
32
  <a href="#api-reference">API Reference</a> •
32
33
  <a href="#reference">Reference</a> •
@@ -49,6 +50,7 @@
49
50
  - [Domain Agent Modules](#domain-agent-modules)
50
51
  - [Getting Started](#getting-started)
51
52
  - [Installation](#installation)
53
+ - [MCP Server](#mcp-server)
52
54
  - [Architecture](#architecture)
53
55
  - [API Reference](#api-reference)
54
56
  - [Reference](#reference)
@@ -98,89 +100,99 @@ TypeScript-first, built on the Vercel AI SDK, ships with all provider SDKs (Open
98
100
 
99
101
  ## Use with Cursor, Claude Code, and Codex
100
102
 
101
- Coding agents are powerful executors -- but they build faster and better when they start from a structured plan instead of a vague prompt. sweagent generates the blueprints; your coding agent implements them.
103
+ sweagent is an MCP server. Install it once, add one config to your IDE, and all 13 domain agents are available directly in your chat -- planning, requirements, data modeling, API design, auth, architecture, and more. No scripts, no code, no file juggling.
102
104
 
103
105
  ```mermaid
104
106
  flowchart LR
105
- Requirement["Your idea"] --> sweagent["sweagent"]
106
- sweagent --> Plan["plan.md / JSON spec"]
107
- Plan --> Cursor["Cursor"]
108
- Plan --> ClaudeCode["Claude Code"]
109
- Plan --> Codex["Codex"]
110
- Cursor --> Code["Production code"]
111
- ClaudeCode --> Code
112
- Codex --> Code
107
+ You["You type a prompt"] -->|"MCP"| Server["sweagent"]
108
+ Server --> Plan["plan"]
109
+ Server --> Req["gather_requirements"]
110
+ Server --> Data["design_data_model"]
111
+ Server --> Api["design_api"]
112
+ Server --> More["... 9 more tools"]
113
+ Plan --> Agent["Your coding agent implements it"]
114
+ Req --> Agent
115
+ Data --> Agent
116
+ Api --> Agent
117
+ More --> Agent
113
118
  ```
114
119
 
115
- ### With Cursor
120
+ ### 1. Install
116
121
 
117
- Generate a plan, save it to your project, and reference it in Cursor chat or `.cursor/rules/`:
118
-
119
- ```typescript
120
- import { runPlanningAgent } from 'sweagent';
121
- import { writeFileSync } from 'fs';
122
-
123
- const result = await runPlanningAgent({
124
- input: 'E-commerce with users, products, cart, checkout, admin dashboard',
125
- model: { provider: 'openai', model: 'gpt-4o-mini' },
126
- });
127
-
128
- writeFileSync('plan.md', result.output);
129
- // Open plan.md in Cursor and say: "Implement this plan step by step"
130
- // Or copy plan.md to .cursor/rules/ so every agent session uses it as context
122
+ ```bash
123
+ npm install -g sweagent
131
124
  ```
132
125
 
133
- ### With Claude Code
134
-
135
- Generate a plan and save it as `CLAUDE.md` or a reference file. Claude Code automatically reads `CLAUDE.md` for project context:
126
+ ### 2. Add the config for your IDE
136
127
 
137
- ```typescript
138
- import { runPlanningAgent } from 'sweagent';
139
- import { writeFileSync } from 'fs';
128
+ **Cursor** -- create `.cursor/mcp.json` in your project root:
140
129
 
141
- const result = await runPlanningAgent({
142
- input: 'SaaS dashboard with multi-tenancy, billing, and analytics',
143
- model: { provider: 'anthropic', model: 'claude-sonnet-4-20250514' },
144
- });
130
+ ```json
131
+ {
132
+ "mcpServers": {
133
+ "sweagent": {
134
+ "command": "sweagent",
135
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
136
+ }
137
+ }
138
+ }
139
+ ```
145
140
 
146
- // Option 1: Save as CLAUDE.md for automatic context
147
- writeFileSync('CLAUDE.md', `# Implementation Plan\n\n${result.output}`);
141
+ **VS Code (Copilot)** -- create `.vscode/mcp.json` in your project root:
142
+
143
+ ```json
144
+ {
145
+ "servers": {
146
+ "sweagent": {
147
+ "command": "sweagent",
148
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
149
+ }
150
+ }
151
+ }
152
+ ```
148
153
 
149
- // Option 2: Save as plan.md and reference it
150
- writeFileSync('plan.md', result.output);
151
- // Then tell Claude Code: "Read plan.md and implement phase 1"
154
+ **Windsurf** -- edit `~/.codeium/windsurf/mcp_config.json`:
155
+
156
+ ```json
157
+ {
158
+ "mcpServers": {
159
+ "sweagent": {
160
+ "command": "sweagent",
161
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
162
+ }
163
+ }
164
+ }
152
165
  ```
153
166
 
154
- ### With Codex
167
+ **Claude Desktop** -- edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
168
+
169
+ ```json
170
+ {
171
+ "mcpServers": {
172
+ "sweagent": {
173
+ "command": "sweagent",
174
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
175
+ }
176
+ }
177
+ }
178
+ ```
155
179
 
156
- Codex works best with structured, machine-readable specs. Use the Requirement Gatherer or Data Modeler for JSON output:
180
+ > **Don't want a global install?** Replace `"command": "sweagent"` with `"command": "npx"` and add `"args": ["-y", "sweagent"]`. See [MCP Server](#mcp-server) for all options including from-source setup.
157
181
 
158
- ```typescript
159
- import { runRequirementGathererAgent } from 'sweagent';
160
- import { writeFileSync } from 'fs';
161
-
162
- const result = await runRequirementGathererAgent({
163
- input: 'Task manager with teams, Kanban boards, and time tracking',
164
- model: { provider: 'openai', model: 'gpt-4o-mini' },
165
- maxIterations: 15,
166
- });
182
+ ### 3. Restart your IDE and start prompting
167
183
 
168
- // Structured JSON with actors, flows, stories, modules, DB schema, API design
169
- writeFileSync('requirements.json', result.output);
170
- // Feed requirements.json to Codex as context for implementation
171
- ```
184
+ Open the chat and try:
172
185
 
173
- ### Why this works
186
+ - _"Use the plan tool to plan a task manager app with teams, Kanban boards, and time tracking."_
187
+ - _"Use the gather_requirements tool to extract structured requirements for an e-commerce platform."_
188
+ - _"Use the design_data_model tool to design a PostgreSQL schema for a SaaS billing system."_
174
189
 
175
- Without sweagent, a coding agent receives "build a task manager" and immediately starts guessing. With sweagent, it receives:
190
+ The agent calls sweagent, gets back a structured blueprint, and can immediately start implementing it.
176
191
 
177
- - **11-section markdown plan** with tech stack, data models, API routes, auth flow, implementation order, edge cases, and testing checklist
178
- - **Structured JSON requirements** with actors, user flows, stories, and module breakdowns
179
- - **Database schemas** with exact field types, relationships, indexes, and validation rules
180
- - **API contracts** with endpoints, methods, request/response shapes, and auth requirements
181
- - **Frontend architecture** with pages, components, routing, and state management
192
+ ### Full reference
182
193
 
183
- The coding agent stops guessing and starts executing a professional-grade blueprint.
194
+ - [MCP Server](#mcp-server) -- all 13 tools, input parameters, multi-provider setup, troubleshooting
195
+ - [Getting Started](#getting-started) and [Full Pipeline](#full-pipeline) -- programmatic API for scripted pipelines, CI, or chaining multiple agents in code
184
196
 
185
197
  ---
186
198
 
@@ -1031,6 +1043,300 @@ npm run example -- examples/hello-world/01-hello-world.ts
1031
1043
 
1032
1044
  ---
1033
1045
 
1046
+ ## MCP Server
1047
+
1048
+ sweagent is also a **Model Context Protocol (MCP) server**. Install it once and every MCP-compatible IDE or tool -- Cursor, VS Code, Windsurf, Claude Desktop, and more -- can call any of the 13 domain agents directly from the chat interface. No wrapper scripts, no code to write.
1049
+
1050
+ ```mermaid
1051
+ flowchart LR
1052
+ IDE["Cursor / VS Code / Windsurf / Claude Desktop"] -->|"MCP stdio"| Server["sweagent MCP Server"]
1053
+ Server --> Plan["plan"]
1054
+ Server --> Req["gather_requirements"]
1055
+ Server --> Data["design_data_model"]
1056
+ Server --> Api["design_api"]
1057
+ Server --> Auth["design_auth"]
1058
+ Server --> More["... 8 more tools"]
1059
+ ```
1060
+
1061
+ ### Quick Start
1062
+
1063
+ **1. Install sweagent from npm:**
1064
+
1065
+ ```bash
1066
+ npm install -g sweagent
1067
+ ```
1068
+
1069
+ This installs the `sweagent` command globally on your machine. Requires Node.js >= 18.
1070
+
1071
+ **2. Set your API key:**
1072
+
1073
+ You need at least one AI provider API key. Export it in your shell or pass it via the IDE config (shown below):
1074
+
1075
+ ```bash
1076
+ export OPENAI_API_KEY=sk-...
1077
+ # or ANTHROPIC_API_KEY, or GOOGLE_GENERATIVE_AI_API_KEY
1078
+ ```
1079
+
1080
+ **3. Add the config to your IDE** (pick your IDE below) **and restart.**
1081
+
1082
+ **4. Verify** -- ask the chat agent: _"Use the hello_world tool to test the sweagent server."_
1083
+
1084
+ > **No global install?** You can skip step 1 and use `npx -y sweagent` instead. The IDE configs below show both options.
1085
+
1086
+ ### How it runs
1087
+
1088
+ The MCP server communicates over **stdio**. Your IDE starts it automatically -- you do not run these commands yourself. Under the hood, the IDE runs one of:
1089
+
1090
+ ```bash
1091
+ # If you installed globally (npm install -g sweagent)
1092
+ sweagent
1093
+
1094
+ # If you prefer npx (no install needed, downloads on first use)
1095
+ npx -y sweagent
1096
+
1097
+ # If you cloned the repo and built from source
1098
+ node --env-file=.env dist/stdio.js
1099
+ ```
1100
+
1101
+ ### Setup with Cursor
1102
+
1103
+ Create `.cursor/mcp.json` in your project root:
1104
+
1105
+ **Option A -- Global install (recommended):**
1106
+
1107
+ ```json
1108
+ {
1109
+ "mcpServers": {
1110
+ "sweagent": {
1111
+ "command": "sweagent",
1112
+ "env": {
1113
+ "OPENAI_API_KEY": "your-openai-api-key"
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ ```
1119
+
1120
+ **Option B -- npx (no install needed):**
1121
+
1122
+ ```json
1123
+ {
1124
+ "mcpServers": {
1125
+ "sweagent": {
1126
+ "command": "npx",
1127
+ "args": ["-y", "sweagent"],
1128
+ "env": {
1129
+ "OPENAI_API_KEY": "your-openai-api-key"
1130
+ }
1131
+ }
1132
+ }
1133
+ }
1134
+ ```
1135
+
1136
+ **Option C -- From source (local clone):**
1137
+
1138
+ ```json
1139
+ {
1140
+ "mcpServers": {
1141
+ "sweagent": {
1142
+ "command": "node",
1143
+ "args": ["--env-file=.env", "dist/stdio.js"]
1144
+ }
1145
+ }
1146
+ }
1147
+ ```
1148
+
1149
+ Cursor auto-discovers `.cursor/mcp.json`. After saving, restart Cursor or reload the window. The sweagent tools appear in the Cursor chat tool list.
1150
+
1151
+ ### Setup with VS Code (GitHub Copilot)
1152
+
1153
+ Create `.vscode/mcp.json` in your project root:
1154
+
1155
+ **Option A -- Global install:**
1156
+
1157
+ ```json
1158
+ {
1159
+ "servers": {
1160
+ "sweagent": {
1161
+ "command": "sweagent",
1162
+ "env": {
1163
+ "OPENAI_API_KEY": "your-openai-api-key"
1164
+ }
1165
+ }
1166
+ }
1167
+ }
1168
+ ```
1169
+
1170
+ **Option B -- npx:**
1171
+
1172
+ ```json
1173
+ {
1174
+ "servers": {
1175
+ "sweagent": {
1176
+ "command": "npx",
1177
+ "args": ["-y", "sweagent"],
1178
+ "env": {
1179
+ "OPENAI_API_KEY": "your-openai-api-key"
1180
+ }
1181
+ }
1182
+ }
1183
+ }
1184
+ ```
1185
+
1186
+ VS Code discovers MCP servers from `.vscode/mcp.json` automatically. You can also configure servers globally via **MCP: Open User Configuration** in the Command Palette. After saving, open the Copilot chat panel -- the sweagent tools are available to the agent.
1187
+
1188
+ ### Setup with Windsurf
1189
+
1190
+ Edit (or create) the Windsurf MCP config file at `~/.codeium/windsurf/mcp_config.json`:
1191
+
1192
+ **Option A -- Global install:**
1193
+
1194
+ ```json
1195
+ {
1196
+ "mcpServers": {
1197
+ "sweagent": {
1198
+ "command": "sweagent",
1199
+ "env": {
1200
+ "OPENAI_API_KEY": "your-openai-api-key"
1201
+ }
1202
+ }
1203
+ }
1204
+ }
1205
+ ```
1206
+
1207
+ **Option B -- npx:**
1208
+
1209
+ ```json
1210
+ {
1211
+ "mcpServers": {
1212
+ "sweagent": {
1213
+ "command": "npx",
1214
+ "args": ["-y", "sweagent"],
1215
+ "env": {
1216
+ "OPENAI_API_KEY": "your-openai-api-key"
1217
+ }
1218
+ }
1219
+ }
1220
+ }
1221
+ ```
1222
+
1223
+ Restart Windsurf after saving. The sweagent tools appear in the Cascade chat.
1224
+
1225
+ ### Setup with Claude Desktop
1226
+
1227
+ Edit the Claude Desktop config file:
1228
+
1229
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
1230
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
1231
+
1232
+ **Option A -- Global install:**
1233
+
1234
+ ```json
1235
+ {
1236
+ "mcpServers": {
1237
+ "sweagent": {
1238
+ "command": "sweagent",
1239
+ "env": {
1240
+ "OPENAI_API_KEY": "your-openai-api-key"
1241
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+ ```
1246
+
1247
+ **Option B -- npx:**
1248
+
1249
+ ```json
1250
+ {
1251
+ "mcpServers": {
1252
+ "sweagent": {
1253
+ "command": "npx",
1254
+ "args": ["-y", "sweagent"],
1255
+ "env": {
1256
+ "OPENAI_API_KEY": "your-openai-api-key"
1257
+ }
1258
+ }
1259
+ }
1260
+ }
1261
+ ```
1262
+
1263
+ Restart Claude Desktop after saving. The sweagent tools appear in the tool list (hammer icon) in a new conversation.
1264
+
1265
+ ### Available Tools
1266
+
1267
+ All 13 domain agents are exposed as MCP tools:
1268
+
1269
+ | Tool | Description |
1270
+ | --------------------- | ----------------------------------------------------------------------------------------------------- |
1271
+ | `plan` | Generate a full software plan (discovery, requirements, design, synthesis) from a project description |
1272
+ | `gather_requirements` | Extract structured requirements (actors, flows, stories, modules) from a project description |
1273
+ | `design_data_model` | Design a database schema (MongoDB or PostgreSQL) with entities, relations, and indexes |
1274
+ | `design_api` | Design REST or GraphQL API contracts (endpoints, request/response schemas) from requirements |
1275
+ | `design_auth` | Design authentication and authorization strategy (providers, roles, permissions, flows) |
1276
+ | `architect_backend` | Design backend architecture (folder structure, services, middleware, deployment) |
1277
+ | `architect_frontend` | Design frontend architecture (components, state management, routing, styling) |
1278
+ | `build_express` | Generate Express.js REST API configuration and boilerplate from an API design |
1279
+ | `build_apollo` | Generate Apollo GraphQL subgraph configuration and resolvers from an API design |
1280
+ | `build_react` | Generate React + Vite application configuration and components from a GraphQL schema |
1281
+ | `build_nextjs` | Generate Next.js App Router configuration and pages from requirements |
1282
+ | `plan_execution` | Create a phased execution plan with edge-case analysis and testing strategy |
1283
+ | `hello_world` | Test agent that greets users -- use to verify the MCP server is working |
1284
+
1285
+ ### Tool Input Parameters
1286
+
1287
+ Every tool accepts the same input shape:
1288
+
1289
+ | Parameter | Type | Required | Description |
1290
+ | ------------- | ------------------------------------- | -------- | -------------------------------------------------------------------------------------- |
1291
+ | `input` | `string` | Yes | Natural language description of what to build or design |
1292
+ | `provider` | `"openai" \| "anthropic" \| "google"` | No | LLM provider (defaults to `openai`) |
1293
+ | `model` | `string` | No | Model name, e.g. `gpt-4o-mini`, `claude-sonnet-4-20250514` (defaults to `gpt-4o-mini`) |
1294
+ | `temperature` | `number` (0--1) | No | Sampling temperature |
1295
+
1296
+ ### Verify the Server
1297
+
1298
+ After configuring your IDE, verify the connection by asking the chat agent:
1299
+
1300
+ > Use the hello_world tool to verify the sweagent MCP server is working.
1301
+
1302
+ If the server is running correctly, the agent will call the `hello_world` tool and return a greeting.
1303
+
1304
+ ### Using Multiple Providers
1305
+
1306
+ Pass `provider` and `model` to any tool call to override the default (OpenAI gpt-4o-mini). Make sure the corresponding API key is set in the `env` block of your MCP config:
1307
+
1308
+ ```json
1309
+ {
1310
+ "mcpServers": {
1311
+ "sweagent": {
1312
+ "command": "npx",
1313
+ "args": ["-y", "sweagent"],
1314
+ "env": {
1315
+ "OPENAI_API_KEY": "your-openai-api-key",
1316
+ "ANTHROPIC_API_KEY": "your-anthropic-api-key",
1317
+ "GOOGLE_GENERATIVE_AI_API_KEY": "your-google-api-key"
1318
+ }
1319
+ }
1320
+ }
1321
+ }
1322
+ ```
1323
+
1324
+ Then tell the agent which provider to use:
1325
+
1326
+ > Use the plan tool with provider "anthropic" and model "claude-sonnet-4-20250514" to plan a task manager app with teams, Kanban boards, and time tracking.
1327
+
1328
+ ### Troubleshooting MCP
1329
+
1330
+ **Server not appearing in tool list** -- Restart your IDE after saving the config file. Check that the config file is in the correct location for your IDE.
1331
+
1332
+ **API key errors** -- Make sure the API key is set in the `env` block of your MCP config, not just in a `.env` file (unless you are using the `--env-file` flag with the node command).
1333
+
1334
+ **npx timeout or failure** -- Run `npx sweagent` manually in a terminal to check for errors. Make sure Node.js >= 18 is installed.
1335
+
1336
+ **Tool returns an error** -- The MCP server catches errors and returns them as text. Check that the `input` parameter contains a meaningful project description, not an empty string.
1337
+
1338
+ ---
1339
+
1034
1340
  ## Architecture
1035
1341
 
1036
1342
  ### System overview
@@ -1358,6 +1664,8 @@ const context = createPlanningContextBuilder()
1358
1664
 
1359
1665
  ### MCP
1360
1666
 
1667
+ sweagent ships as a standalone **MCP server** that exposes all 13 domain agents as tools. See [MCP Server](#mcp-server) for IDE setup and tool reference.
1668
+
1361
1669
  **BaseMcpClient** -- Base class for MCP clients. Lazy connection, `callTool(name, args)` for invocation.
1362
1670
 
1363
1671
  **BaseMcpClient.resolveConfig(options, resolveOpts)** -- Build config from options and env (e.g. `MCP_URL`, `MCP_COMMAND`, `MCP_ARGS`).