Skip to main content
Glama
pam-supastellar

CashChat MCP Server

README.md
# CashChat MCP Server

**Connect your financial data to AI assistants like Claude**

CashChat MCP Server exposes your CashChat financial data to AI assistants via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io). It supports both local stdio connections and remote URL-based connections with OAuth 2.0 authentication.

## Features

- šŸ” **OAuth 2.0 Authentication** - Secure URL-based connections for Claude Desktop
- šŸ’° **Transaction Management** - Query, add, update, and delete transactions
- šŸ“Š **Financial Analytics** - Get spending summaries and category breakdowns
- āš™ļø **Settings Control** - Manage currency preferences and AI agent instructions
- šŸš€ **Multiple Deployment Options** - Run locally, Node.js server, or Cloudflare Workers
- šŸ”Œ **MCP Standard Compliant** - Works with any MCP-compatible AI assistant

## Quick Start

### For Claude Desktop Users (URL-based connection)

This is the recommended way to connect CashChat to Claude Desktop using a publicly accessible server.

#### 1. Get Your CashChat API Key

Sign up at [CashChat](https://cashchat.supastellar.dev) and get your API key from the settings page.

#### 2. Connect to the Public Server

Add this configuration to your Claude Desktop config file:

**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "cashchat": {
      "url": "https://cashchat.supastellar.dev/sse",
      "oauth": {
        "authUrl": "https://cashchat.supastellar.dev/oauth/authorize",
        "tokenUrl": "https://cashchat.supastellar.dev/oauth/token",
        "clientId": "cashchat-mcp-server",
        "scopes": ["read", "write"]
      }
    }
  }
}
```

#### 3. Restart Claude Desktop

Restart Claude Desktop and you'll be prompted to authorize the connection. Click "Authorize" and you're ready to go!

#### 4. Try It Out

In Claude Desktop, try asking:
- "What did I spend on groceries this month?"
- "Add a transaction: $50 for dinner at Joe's Restaurant"
- "Show me my spending summary for this week"

---

## Local Development & Self-Hosting

### Prerequisites

- Node.js 18 or higher
- npm or yarn
- CashChat API key

### Installation

1. **Clone the repository:**

```bash
git clone https://github.com/supastellar/cashchat-mcp
cd cashchat-mcp
```

2. **Install dependencies:**

```bash
npm install
```

3. **Configure environment variables:**

```bash
cp .env.example .env
```

Edit `.env` and add your CashChat API key:

```env
CASHCHAT_API_KEY=your_api_key_here
PORT=3000
SERVER_URL=http://localhost:3000
```

4. **Build the project:**

```bash
npm run build
```

5. **Start the server:**

```bash
npm run start:server
```

The server will be running at `http://localhost:3000`.

### Testing Locally

Connect Claude Desktop to your local server by updating the config:

```json
{
  "mcpServers": {
    "cashchat": {
      "url": "http://localhost:3000/sse",
      "oauth": {
        "authUrl": "http://localhost:3000/oauth/authorize",
        "tokenUrl": "http://localhost:3000/oauth/token",
        "clientId": "cashchat-mcp-server",
        "scopes": ["read", "write"]
      }
    }
  }
}
```

**Note:** Claude Desktop may require HTTPS for OAuth. For local testing with HTTPS, use a tool like [ngrok](https://ngrok.com/) or [localtunnel](https://localtunnel.me/).

---

## Legacy stdio Mode (for local-only setup)

If you prefer the classic stdio-based local connection without OAuth:

### Claude Desktop Config (stdio mode)

```json
{
  "mcpServers": {
    "cashchat": {
      "command": "node",
      "args": ["/absolute/path/to/cashchat-mcp/build/index.js"],
      "env": {
        "CASHCHAT_API_KEY": "your_api_key_here"
      }
    }
  }
}
```

This mode runs the server as a subprocess and communicates via stdin/stdout. No HTTP server or OAuth required.

---

## Available Tools

The MCP server provides 8 tools for interacting with your financial data:

### Transaction Tools

#### `get_transactions`
Retrieve transactions with optional filters.

**Parameters:**
- `startDate` (optional): Start date (YYYY-MM-DD)
- `endDate` (optional): End date (YYYY-MM-DD)
- `category` (optional): Filter by category
- `limit` (optional): Max results (default: 50)
- `offset` (optional): Pagination offset

**Example:**
```
Get my transactions from January 2024
```

#### `add_transaction`
Add a new transaction.

**Parameters:**
- `amount` (required): Transaction amount
- `category` (required): Category (e.g., Food, Transport)
- `date` (required): Date (YYYY-MM-DD)
- `type` (optional): 'expense' or 'income' (default: expense)
- `note` (optional): Description
- `name` (optional): Merchant name

**Example:**
```
Add a transaction: $75 for groceries at Whole Foods on 2024-01-15
```

#### `update_transaction`
Update an existing transaction.

**Parameters:**
- `id` (required): Transaction ID
- `amount` (optional): New amount
- `category` (optional): New category
- `note` (optional): New note
- `name` (optional): New merchant name

#### `delete_transaction`
Delete a transaction.

**Parameters:**
- `id` (required): Transaction ID to delete

### Analytics Tools

#### `get_summary`
Get spending summary for a time period.

**Parameters:**
- `period` (required): 'day', 'week', 'month', or 'year'
- `date` (optional): Reference date (defaults to today)

**Example:**
```
Show me my spending summary for this month
```

#### `get_categories`
List all available transaction categories.

**Example:**
```
What categories can I use?
```

### Settings Tools

#### `get_settings`
Get your CashChat settings.

#### `update_settings`
Update your CashChat settings.

**Parameters:**
- `preferredCurrency` (optional): Currency code (USD, CAD, EUR, etc.)
- `agentInstructions` (optional): Custom instructions for AI assistant

---

## Deployment

For production deployment instructions, see [DEPLOYMENT.md](./DEPLOYMENT.md).

### Quick Deployment Options

#### Railway (Recommended)

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/cashchat-mcp)

1. Click the button above
2. Add your `CASHCHAT_API_KEY`
3. Deploy!

#### Cloudflare Workers

```bash
npm install -g wrangler
wrangler login
wrangler secret put CASHCHAT_API_KEY
wrangler deploy
```

See [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed instructions.

---

## Architecture

### URL-Based Mode (HTTP + SSE + OAuth)

```
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”          ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  Claude Desktop │          │  CashChat MCP    │
│                 │          │  Server (HTTP)   │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤          ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│                 │          │                  │
│  1. OAuth Flow  │ ◄───────►│  /oauth/*        │
│                 │          │                  │
│  2. SSE Connect │ ◄───────►│  /sse            │
│                 │          │                  │
│  3. MCP Tools   │ ◄───────►│  MCP Server      │
│                 │          │                  │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜          ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                      │
                                      ā–¼
                             ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                             │  CashChat API    │
                             │  (Backend)       │
                             ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
```

### Legacy stdio Mode

```
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”          ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  Claude Desktop │          │  CashChat MCP    │
│                 │          │  Server (stdio)  │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤          ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│                 │          │                  │
│  stdio pipe     │ ◄───────►│  MCP Server      │
│                 │          │                  │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜          ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                      │
                                      ā–¼
                             ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                             │  CashChat API    │
                             │  (Backend)       │
                             ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
```

---

## Security

- **OAuth 2.0** with PKCE support for secure authorization
- **Bearer token authentication** for API requests
- **HTTPS required** in production
- **Token expiration** (30 days default)
- **Scope-based permissions** (read/write)

### Production Security Recommendations

1. Use HTTPS only (no HTTP in production)
2. Set `OAUTH_CLIENT_SECRET` for additional security
3. Implement rate limiting
4. Use a proper database for token storage (not in-memory)
5. Rotate API keys regularly
6. Monitor access logs

---

## Troubleshooting

### "Connection refused" error

- Check if the server is running
- Verify the URL in your Claude Desktop config
- Ensure firewall allows the port

### OAuth authorization fails

- Confirm `SERVER_URL` is publicly accessible
- Check that URLs in Claude config match your server
- Verify HTTPS is enabled (required by Claude Desktop)

### "Invalid API key" error

- Check your `CASHCHAT_API_KEY` is correct
- Verify the API key is active in your CashChat account

### Tools not showing up in Claude

- Restart Claude Desktop after config changes
- Check server logs for errors
- Verify OAuth flow completed successfully

For more help, see [DEPLOYMENT.md](./DEPLOYMENT.md) or open an issue.

---

## Development

### Project Structure

```
cashchat-mcp/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts              # Legacy stdio server
│   ā”œā”€ā”€ server.ts             # HTTP/SSE server with OAuth
│   ā”œā”€ā”€ worker.ts             # Cloudflare Workers version
│   ā”œā”€ā”€ types.ts              # TypeScript types
│   ā”œā”€ā”€ api/
│   │   └── client.ts         # CashChat API client
│   ā”œā”€ā”€ auth/
│   │   ā”œā”€ā”€ tokenStore.ts     # OAuth token storage
│   │   ā”œā”€ā”€ middleware.ts     # Auth middleware
│   │   └── oauthRoutes.ts    # OAuth endpoints
│   └── tools/
│       ā”œā”€ā”€ transactions.ts   # Transaction tools
│       └── summary.ts        # Analytics tools
ā”œā”€ā”€ build/                    # Compiled JavaScript
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
ā”œā”€ā”€ wrangler.toml            # Cloudflare Workers config
└── README.md
```

### Scripts

- `npm run build` - Compile TypeScript
- `npm run dev` - Watch mode for development
- `npm start` - Run stdio server (legacy)
- `npm run start:server` - Run HTTP/SSE server
- `npm run dev:server` - Development mode with auto-reload

### Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

---

## License

MIT License - see [LICENSE](./LICENSE) for details.

---

## Links

- **CashChat:** https://cashchat.supastellar.dev
- **MCP Documentation:** https://modelcontextprotocol.io
- **Claude Desktop:** https://claude.ai/download
- **GitHub:** https://github.com/supastellar/cashchat-mcp
- **Issues:** https://github.com/supastellar/cashchat-mcp/issues

---

## Support

Need help?

- šŸ“– Check the [DEPLOYMENT.md](./DEPLOYMENT.md) guide
- šŸ› Report bugs on [GitHub Issues](https://github.com/supastellar/cashchat-mcp/issues)
- šŸ’¬ Questions? Open a [Discussion](https://github.com/supastellar/cashchat-mcp/discussions)

---

**Built with ā¤ļø by [Supa Stellar](https://supastellar.dev)**

TDQS

A3.5/5.0

Scored across 8 tools

Disambiguation5/5

Every tool has a clearly distinct purpose targeting specific resources and actions. For example, add_transaction, update_transaction, and delete_transaction handle different lifecycle stages of transactions, while get_categories, get_settings, and update_settings manage separate aspects of the system. There is no ambiguity or overlap in functionality.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern using snake_case. The verbs (add, delete, get, update) are applied logically to corresponding nouns (transaction, categories, settings, summary), creating a predictable and readable naming convention throughout the tool set.

Tool Count5/5

With 8 tools, this server is well-scoped for a personal finance/transaction management domain. Each tool earns its place by covering essential operations like CRUD for transactions, settings management, and summary reporting, without being overly sparse or bloated.

Completeness5/5

The tool surface provides complete coverage for the apparent domain of transaction management. It includes full CRUD for transactions (add, get, update, delete), settings management (get and update), and auxiliary functions like categories and summaries, ensuring agents can handle typical workflows without dead ends.

Maintenance

ActivityInactive
ResponsivenessNo issues