|
| 1 | +# rh-agent-tools |
| 2 | + |
| 3 | +AI-native Robinhood trading interface — TypeScript monorepo with a standalone API client and MCP server. |
| 4 | + |
| 5 | +## Project Structure |
| 6 | +- `packages/client/` — `@rh-agent-tools/client`: Standalone Robinhood API client |
| 7 | +- `packages/server/` — `rh-agent-tools`: MCP server with 18 tools |
| 8 | +- `.claude/skills/` — Claude Code skills for interactive use (SKILL.md only, no scripts) |
| 9 | +- `docs/` — Architecture, access controls, use cases, contributing |
| 10 | + |
| 11 | +## Tech Stack |
| 12 | +- **Runtime**: Bun |
| 13 | +- **Language**: TypeScript (strict mode, ESM-only) |
| 14 | +- **MCP SDK**: `@modelcontextprotocol/sdk` v1.12+ (McpServer + StdioServerTransport) |
| 15 | +- **Validation**: Zod v3.24 (API responses + MCP tool schemas) |
| 16 | +- **Testing**: Vitest (not `bun test` — module isolation matters) |
| 17 | +- **Linting**: Biome v2 |
| 18 | +- **Browser Auth**: playwright-core (browser auth) |
| 19 | + |
| 20 | +## Running the MCP Server |
| 21 | +```bash |
| 22 | +bun install |
| 23 | +bun packages/server/bin/rh-agent-tools.ts |
| 24 | +``` |
| 25 | + |
| 26 | +## Development |
| 27 | +```bash |
| 28 | +bun run typecheck # tsc --noEmit on both packages |
| 29 | +bun run check # biome lint + format |
| 30 | +npx vitest run # all tests (use vitest, NOT bun test) |
| 31 | +``` |
| 32 | + |
| 33 | +## Skills |
| 34 | +Canonical skill source is `packages/server/skills/`. Local `.claude/skills/` contains symlinks for development. |
| 35 | + |
| 36 | +Install MCP server + skills: `bun packages/server/bin/rh-agent-tools.ts install` |
| 37 | + |
| 38 | +Skills use three-layer progressive disclosure: |
| 39 | +1. **SKILL.md** — MCP tool orchestration (default) |
| 40 | +2. **reference.md** — MCP tool API details (loaded on demand) |
| 41 | +3. **client-api.md** — TypeScript client library patterns (advanced, loaded on demand) |
| 42 | + |
| 43 | +Available skills: |
| 44 | +- `robinhood-setup` - Initial auth setup |
| 45 | +- `robinhood-portfolio` - Portfolio and holdings |
| 46 | +- `robinhood-research` - Stock research and analysis |
| 47 | +- `robinhood-trade` - Order placement with safety checks |
| 48 | +- `robinhood-options` - Options chain analysis |
| 49 | + |
| 50 | +## Client Patterns |
| 51 | +```typescript |
| 52 | +import { RobinhoodClient, getClient } from "@rh-agent-tools/client"; |
| 53 | + |
| 54 | +// Class-based |
| 55 | +const client = new RobinhoodClient(); |
| 56 | +await client.restoreSession(); |
| 57 | +const quotes = await client.getQuotes("AAPL"); |
| 58 | + |
| 59 | +// Singleton |
| 60 | +const rh = getClient(); |
| 61 | +await rh.restoreSession(); |
| 62 | +``` |
| 63 | +- All methods are `async` (native `fetch` under the hood) |
| 64 | +- Multi-account is first-class: every account-scoped method accepts `accountNumber` |
| 65 | +- Session cached to `~/.rh-agent-tools/session.enc` (AES-256-GCM, key in OS keychain) |
| 66 | +- Proper exceptions: `AuthenticationError`, `APIError` |
| 67 | +- **Do NOT use `phoenix.robinhood.com`** — it rejects TLS. Use `api.robinhood.com` endpoints only. |
| 68 | + |
| 69 | +## Safety Rules |
| 70 | +- **NEVER** place bulk cancel operations |
| 71 | +- **NEVER** call fund transfer functions |
| 72 | +- **ALWAYS** confirm with user before placing any order |
| 73 | +- Order tools require explicit parameters - no defaults that could cause accidental trades |
| 74 | + |
| 75 | +## Testing |
| 76 | +```bash |
| 77 | +npx vitest run |
| 78 | +``` |
| 79 | +Tests use `vi.mock()` to mock HTTP layer — no real API calls. Use `vitest` (not `bun test`) for correct module isolation. |
0 commit comments