sweagent 0.0.3 → 0.0.5

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,97 @@ 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. Add the config for your IDE
116
121
 
117
- Generate a plan, save it to your project, and reference it in Cursor chat or `.cursor/rules/`:
122
+ No install step needed -- `npx` downloads and runs sweagent automatically on first use. Just create the config file for your IDE and add your API key.
118
123
 
119
- ```typescript
120
- import { runPlanningAgent } from 'sweagent';
121
- import { writeFileSync } from 'fs';
124
+ **Cursor** -- create `.cursor/mcp.json` in your project root:
122
125
 
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
126
+ ```json
127
+ {
128
+ "mcpServers": {
129
+ "sweagent": {
130
+ "command": "npx",
131
+ "args": ["-y", "sweagent"],
132
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
133
+ }
134
+ }
135
+ }
131
136
  ```
132
137
 
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:
136
-
137
- ```typescript
138
- import { runPlanningAgent } from 'sweagent';
139
- import { writeFileSync } from 'fs';
140
-
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
- });
145
-
146
- // Option 1: Save as CLAUDE.md for automatic context
147
- writeFileSync('CLAUDE.md', `# Implementation Plan\n\n${result.output}`);
148
-
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"
138
+ **VS Code (Copilot)** -- create `.vscode/mcp.json` in your project root:
139
+
140
+ ```json
141
+ {
142
+ "servers": {
143
+ "sweagent": {
144
+ "command": "npx",
145
+ "args": ["-y", "sweagent"],
146
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
147
+ }
148
+ }
149
+ }
152
150
  ```
153
151
 
154
- ### With Codex
155
-
156
- Codex works best with structured, machine-readable specs. Use the Requirement Gatherer or Data Modeler for JSON output:
152
+ **Windsurf** -- edit `~/.codeium/windsurf/mcp_config.json`:
153
+
154
+ ```json
155
+ {
156
+ "mcpServers": {
157
+ "sweagent": {
158
+ "command": "npx",
159
+ "args": ["-y", "sweagent"],
160
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
161
+ }
162
+ }
163
+ }
164
+ ```
157
165
 
158
- ```typescript
159
- import { runRequirementGathererAgent } from 'sweagent';
160
- import { writeFileSync } from 'fs';
166
+ **Claude Desktop** -- edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
167
+
168
+ ```json
169
+ {
170
+ "mcpServers": {
171
+ "sweagent": {
172
+ "command": "npx",
173
+ "args": ["-y", "sweagent"],
174
+ "env": { "OPENAI_API_KEY": "your-openai-api-key" }
175
+ }
176
+ }
177
+ }
178
+ ```
161
179
 
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
- });
180
+ ### 2. Restart your IDE and start prompting
167
181
 
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
- ```
182
+ Open the chat and try:
172
183
 
173
- ### Why this works
184
+ - _"Use the plan tool to plan a task manager app with teams, Kanban boards, and time tracking."_
185
+ - _"Use the gather_requirements tool to extract structured requirements for an e-commerce platform."_
186
+ - _"Use the design_data_model tool to design a PostgreSQL schema for a SaaS billing system."_
174
187
 
175
- Without sweagent, a coding agent receives "build a task manager" and immediately starts guessing. With sweagent, it receives:
188
+ The agent calls sweagent, gets back a structured blueprint, and can immediately start implementing it.
176
189
 
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
190
+ ### Full reference
182
191
 
183
- The coding agent stops guessing and starts executing a professional-grade blueprint.
192
+ - [MCP Server](#mcp-server) -- all 13 tools, input parameters, multi-provider setup, troubleshooting
193
+ - [Getting Started](#getting-started) and [Full Pipeline](#full-pipeline) -- programmatic API for scripted pipelines, CI, or chaining multiple agents in code
184
194
 
185
195
  ---
186
196
 
@@ -1031,6 +1041,217 @@ npm run example -- examples/hello-world/01-hello-world.ts
1031
1041
 
1032
1042
  ---
1033
1043
 
1044
+ ## MCP Server
1045
+
1046
+ 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.
1047
+
1048
+ ```mermaid
1049
+ flowchart LR
1050
+ IDE["Cursor / VS Code / Windsurf / Claude Desktop"] -->|"MCP stdio"| Server["sweagent MCP Server"]
1051
+ Server --> Plan["plan"]
1052
+ Server --> Req["gather_requirements"]
1053
+ Server --> Data["design_data_model"]
1054
+ Server --> Api["design_api"]
1055
+ Server --> Auth["design_auth"]
1056
+ Server --> More["... 8 more tools"]
1057
+ ```
1058
+
1059
+ ### Quick Start
1060
+
1061
+ **1. Add the config for your IDE** (pick your IDE below). No install needed -- `npx` downloads sweagent automatically. Requires Node.js >= 18.
1062
+
1063
+ **2. Add your API key** to the `env` block in the config (at least one provider key is required).
1064
+
1065
+ **3. Restart your IDE.**
1066
+
1067
+ **4. Verify** -- ask the chat agent: _"Use the hello_world tool to test the sweagent server."_
1068
+
1069
+ ### How it runs
1070
+
1071
+ The MCP server communicates over **stdio**. Your IDE starts it automatically -- you do not run these commands yourself. Under the hood, the IDE runs:
1072
+
1073
+ ```bash
1074
+ # npx downloads and runs sweagent on first use (recommended)
1075
+ npx -y sweagent
1076
+
1077
+ # If you cloned the repo and built from source
1078
+ node --env-file=.env dist/stdio.js
1079
+ ```
1080
+
1081
+ ### Setup with Cursor
1082
+
1083
+ Create `.cursor/mcp.json` in your project root:
1084
+
1085
+ ```json
1086
+ {
1087
+ "mcpServers": {
1088
+ "sweagent": {
1089
+ "command": "npx",
1090
+ "args": ["-y", "sweagent"],
1091
+ "env": {
1092
+ "OPENAI_API_KEY": "your-openai-api-key"
1093
+ }
1094
+ }
1095
+ }
1096
+ }
1097
+ ```
1098
+
1099
+ Cursor auto-discovers `.cursor/mcp.json`. After saving, restart Cursor or reload the window. The sweagent tools appear in the Cursor chat tool list.
1100
+
1101
+ <details>
1102
+ <summary>From source (local clone)</summary>
1103
+
1104
+ ```json
1105
+ {
1106
+ "mcpServers": {
1107
+ "sweagent": {
1108
+ "command": "node",
1109
+ "args": ["--env-file=.env", "dist/stdio.js"]
1110
+ }
1111
+ }
1112
+ }
1113
+ ```
1114
+
1115
+ </details>
1116
+
1117
+ ### Setup with VS Code (GitHub Copilot)
1118
+
1119
+ Create `.vscode/mcp.json` in your project root:
1120
+
1121
+ ```json
1122
+ {
1123
+ "servers": {
1124
+ "sweagent": {
1125
+ "command": "npx",
1126
+ "args": ["-y", "sweagent"],
1127
+ "env": {
1128
+ "OPENAI_API_KEY": "your-openai-api-key"
1129
+ }
1130
+ }
1131
+ }
1132
+ }
1133
+ ```
1134
+
1135
+ 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.
1136
+
1137
+ ### Setup with Windsurf
1138
+
1139
+ Edit (or create) the Windsurf MCP config file at `~/.codeium/windsurf/mcp_config.json`:
1140
+
1141
+ ```json
1142
+ {
1143
+ "mcpServers": {
1144
+ "sweagent": {
1145
+ "command": "npx",
1146
+ "args": ["-y", "sweagent"],
1147
+ "env": {
1148
+ "OPENAI_API_KEY": "your-openai-api-key"
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+ ```
1154
+
1155
+ Restart Windsurf after saving. The sweagent tools appear in the Cascade chat.
1156
+
1157
+ ### Setup with Claude Desktop
1158
+
1159
+ Edit the Claude Desktop config file:
1160
+
1161
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
1162
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
1163
+
1164
+ ```json
1165
+ {
1166
+ "mcpServers": {
1167
+ "sweagent": {
1168
+ "command": "npx",
1169
+ "args": ["-y", "sweagent"],
1170
+ "env": {
1171
+ "OPENAI_API_KEY": "your-openai-api-key"
1172
+ }
1173
+ }
1174
+ }
1175
+ }
1176
+ ```
1177
+
1178
+ Restart Claude Desktop after saving. The sweagent tools appear in the tool list (hammer icon) in a new conversation.
1179
+
1180
+ ### Available Tools
1181
+
1182
+ All 13 domain agents are exposed as MCP tools:
1183
+
1184
+ | Tool | Description |
1185
+ | --------------------- | ----------------------------------------------------------------------------------------------------- |
1186
+ | `plan` | Generate a full software plan (discovery, requirements, design, synthesis) from a project description |
1187
+ | `gather_requirements` | Extract structured requirements (actors, flows, stories, modules) from a project description |
1188
+ | `design_data_model` | Design a database schema (MongoDB or PostgreSQL) with entities, relations, and indexes |
1189
+ | `design_api` | Design REST or GraphQL API contracts (endpoints, request/response schemas) from requirements |
1190
+ | `design_auth` | Design authentication and authorization strategy (providers, roles, permissions, flows) |
1191
+ | `architect_backend` | Design backend architecture (folder structure, services, middleware, deployment) |
1192
+ | `architect_frontend` | Design frontend architecture (components, state management, routing, styling) |
1193
+ | `build_express` | Generate Express.js REST API configuration and boilerplate from an API design |
1194
+ | `build_apollo` | Generate Apollo GraphQL subgraph configuration and resolvers from an API design |
1195
+ | `build_react` | Generate React + Vite application configuration and components from a GraphQL schema |
1196
+ | `build_nextjs` | Generate Next.js App Router configuration and pages from requirements |
1197
+ | `plan_execution` | Create a phased execution plan with edge-case analysis and testing strategy |
1198
+ | `hello_world` | Test agent that greets users -- use to verify the MCP server is working |
1199
+
1200
+ ### Tool Input Parameters
1201
+
1202
+ Every tool accepts the same input shape:
1203
+
1204
+ | Parameter | Type | Required | Description |
1205
+ | ------------- | ------------------------------------- | -------- | -------------------------------------------------------------------------------------- |
1206
+ | `input` | `string` | Yes | Natural language description of what to build or design |
1207
+ | `provider` | `"openai" \| "anthropic" \| "google"` | No | LLM provider (defaults to `openai`) |
1208
+ | `model` | `string` | No | Model name, e.g. `gpt-4o-mini`, `claude-sonnet-4-20250514` (defaults to `gpt-4o-mini`) |
1209
+ | `temperature` | `number` (0--1) | No | Sampling temperature |
1210
+
1211
+ ### Verify the Server
1212
+
1213
+ After configuring your IDE, verify the connection by asking the chat agent:
1214
+
1215
+ > Use the hello_world tool to verify the sweagent MCP server is working.
1216
+
1217
+ If the server is running correctly, the agent will call the `hello_world` tool and return a greeting.
1218
+
1219
+ ### Using Multiple Providers
1220
+
1221
+ 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:
1222
+
1223
+ ```json
1224
+ {
1225
+ "mcpServers": {
1226
+ "sweagent": {
1227
+ "command": "npx",
1228
+ "args": ["-y", "sweagent"],
1229
+ "env": {
1230
+ "OPENAI_API_KEY": "your-openai-api-key",
1231
+ "ANTHROPIC_API_KEY": "your-anthropic-api-key",
1232
+ "GOOGLE_GENERATIVE_AI_API_KEY": "your-google-api-key"
1233
+ }
1234
+ }
1235
+ }
1236
+ }
1237
+ ```
1238
+
1239
+ Then tell the agent which provider to use:
1240
+
1241
+ > 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.
1242
+
1243
+ ### Troubleshooting MCP
1244
+
1245
+ **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.
1246
+
1247
+ **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).
1248
+
1249
+ **npx timeout or failure** -- Run `npx sweagent` manually in a terminal to check for errors. Make sure Node.js >= 18 is installed.
1250
+
1251
+ **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.
1252
+
1253
+ ---
1254
+
1034
1255
  ## Architecture
1035
1256
 
1036
1257
  ### System overview
@@ -1358,6 +1579,8 @@ const context = createPlanningContextBuilder()
1358
1579
 
1359
1580
  ### MCP
1360
1581
 
1582
+ 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.
1583
+
1361
1584
  **BaseMcpClient** -- Base class for MCP clients. Lazy connection, `callTool(name, args)` for invocation.
1362
1585
 
1363
1586
  **BaseMcpClient.resolveConfig(options, resolveOpts)** -- Build config from options and env (e.g. `MCP_URL`, `MCP_COMMAND`, `MCP_ARGS`).