Bags SDK — MCP Server
Launch a Solana token from your terminal in three steps. 46 MCP tools cover trading, fee configuration, claims, Dexscreener listing, and agent authentication — the AI client does the work.
What is this?
bags-sdk-mcp is an MCP (Model Context Protocol) server that exposes the entire Bags.fm API as tools, resources, and prompts. Any MCP-compatible AI client — Claude Desktop, Claude Code, Cursor, or custom agents — can interact with the Bags.fm ecosystem through natural language.
Key Features
- 46 MCP tools — trading, token launches, fee management, claiming, analytics, Dexscreener, signing, scout, and more
- Fee Config Composer — fluent builder for multi-party fee splits without raw BPS math
- Tiered caching — 5-level TTL cache to stay within the 1,000 req/hr rate limit
- Zero-custody — no private keys stored; all transactions returned unsigned
- Browser wallet signing — localhost signing page connects Phantom, Solflare, Backpack, or Coinbase
- Autonomous agent mode — dual-model orchestration with Hermes 4 + Claude Sonnet
- Dual transport — stdio for desktop clients, Streamable HTTP for remote connections
Who is this for?
- Token creators wanting to launch and manage tokens through conversational AI
- Fee earners who want to track and claim fees hands-free
- Partners building on top of Bags.fm's fee infrastructure
- Developers integrating Bags.fm into AI-powered applications
@bagsfm/bags-sdk and the Bags.fm REST API into a single MCP interface.
Beginner's Guide
Never used MCP before? Never heard of Bags.fm? Start here.
What is MCP?
Model Context Protocol is an open standard that lets AI clients (like Claude Desktop, Claude Code, or Cursor) use external tools. Think of it as a plugin system for AI — instead of the AI only being able to chat, MCP lets it call APIs, read data, and execute actions on your behalf.
When you install an MCP server, your AI client gains new abilities. Install this server and your AI can launch tokens, check wallets, claim fees, and more — all through natural language.
What is Bags.fm?
Bags.fm is a Solana token launch and fee-share platform. Creators launch tokens with built-in fee splits — every trade generates fees that get distributed to creators, team members, and holders automatically. The platform handles the on-chain complexity so you don't have to.
Prerequisites
- Node.js 18+ and npm 9+ — download here
- A Bags.fm API key — free at dev.bags.fm
- An MCP client — Claude Desktop, Claude Code, or Cursor
- A Solana wallet — Phantom, Solflare, Backpack, or Coinbase Wallet (browser extension)
Your First 5 Minutes
- Get your API key from dev.bags.fm
- Run
npx bags-sdk-mcp --setup(or see Installation for other options) - Restart your client
- Type: "What's trending on Bags?"
- The AI calls
bags_top_tokensandbags_launch_feed— you see live data from the Bags.fm ecosystem
Common Gotchas
- Restart after config changes — MCP servers load at startup. After editing your config file, you must restart the client.
- Wallet addresses are Base58 — Solana addresses look like
83xQKBYR4eN8..., not hex. Copy them exactly. - SOL vs lamports — 1 SOL = 1,000,000,000 lamports. Most tools accept SOL amounts and convert internally, but some low-level tools use lamports.
- Two signatures per launch — launching a token requires signing the fee config transaction first, then the launch transaction. The signing page handles both.
- No private keys needed — the server never asks for or stores your keys. You sign in your browser wallet.
Installation
One command
bashnpx bags-sdk-mcp --setup
Get your API key at dev.bags.fm. The wizard detects your MCP clients, asks for your key, and writes the config. Restart your client and you're live.
Claude Code alternative
bashclaude mcp add bags-sdk-mcp -e BAGS_API_KEY=your-key -- npx bags-sdk-mcp
Uninstall
bashnpx bags-sdk-mcp --uninstall
From source
bashgit clone https://github.com/outerheaven199X/Bags-SDK-hackathon.git
cd Bags-SDK-hackathon
cp .env.example .env # add your BAGS_API_KEY
npm install && npm run build
npm start
Verify
bashbags-sdk-mcp --help
Configuration
The recommended way is to run npx bags-sdk-mcp --setup — it handles everything below automatically.
Manual configuration (if the wizard doesn't work)
Add this block to your MCP client's config file:
JSON{
"mcpServers": {
"bags-sdk-mcp": {
"command": "npx",
"args": ["bags-sdk-mcp"],
"env": {
"BAGS_API_KEY": "your-key-here"
}
}
}
}
Config file locations
| Client | Path |
|---|---|
| Claude Desktop (macOS) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Desktop (Windows) | %APPDATA%/Claude/claude_desktop_config.json |
| Cursor | .cursor/mcp.json in project root |
| Claude Code | .mcp.json in project root |
Restart your client after saving.
Quick Start
Once configured, talk to your AI naturally. Here are some things to try:
Launch a coin
Check your portfolio
"What's my portfolio look like? My wallet is ABC123..."
Calls bags_wallet_balance, bags_token_holdings, and bags_claimable_positions for a complete overview.
Claim your fees
"Claim all my fees above 0.01 SOL"
Calls bags_claim_all_fees with a dust threshold. Returns unsigned transactions for each position.
More examples
| Say this | Get this |
|---|---|
| "What's trending on Bags?" | Recent launches and top tokens |
| "Check my wallet" | Balance, holdings, claimable fees |
| "Set up a 50/50 fee split" | Fee config built and signed |
| "List on Dexscreener" | Profile boost order placed |
| "Show pool data for $TOKEN" | Reserves, config, migration status |
Architecture
Project Structure
textbags-sdk-mcp/
├── src/
│ ├── index.ts # Server creation, tool/resource/prompt registration
│ ├── transport/
│ │ ├── stdio.ts # Default transport (Claude Desktop)
│ │ └── http.ts # Streamable HTTP transport (Express)
│ ├── client/
│ │ ├── bags-sdk-wrapper.ts # Singleton BagsSDK instance
│ │ ├── bags-rest.ts # Direct REST client for undocumented endpoints
│ │ ├── cache.ts # Tiered TTL cache (5 levels)
│ │ └── types.ts # TypeScript types for API responses
│ ├── tools/ # 46 MCP tools organized by domain
│ │ ├── trading/ # quote, swap
│ │ ├── launch/ # feed, create-info, create-tx, launch-full
│ │ ├── fees/ # resolve-wallet, resolve-bulk, create-config, ...
│ │ ├── claiming/ # positions, claim, claim-all
│ │ ├── partner/ # stats, claim, config
│ │ ├── dexscreener/ # availability, order, payment
│ │ ├── agent/ # auth-init, login, wallets, keys, bootstrap
│ │ ├── state/ # pools, pool, pool-config
│ │ ├── analytics/ # creators, lifetime-fees, claim-stats, top-tokens
│ │ ├── solana/ # send-tx, balance, holdings
│ │ ├── signing/ # open-signing-page, open-launch-page
│ │ └── _registry.ts # Imports and registers all 46 tools
│ ├── resources/ # 4 MCP resources
│ ├── prompts/ # 8 MCP prompts
│ ├── composer/ # Fee Config Builder + templates + validator
│ ├── agent/ # Autonomous agent mode
│ └── utils/ # Constants, errors, formatting
├── bin/
│ └── bags-sdk-mcp.ts # CLI entry point
└── docs/
└── index.html # This documentation
Two Client Layers
| Layer | When Used | Examples |
|---|---|---|
SDK (@bagsfm/bags-sdk) | Typed methods exist | Quotes, swaps, claiming, creators, lifetime fees |
REST (bags-rest.ts) | No SDK method available | Launch feed, pools, fee admin, agent auth, dexscreener |
SDK Service Mapping
| Service | Property | Key Methods |
|---|---|---|
| Trading | sdk.trade | getQuote(), createSwapTransaction() |
| Fees/Claiming | sdk.fee | getAllClaimablePositions(), getClaimTransaction() |
| State | sdk.state | getTokenCreators(), getTokenLifetimeFees() |
| Config | sdk.config | createBagsFeeShareConfig() |
| Token Launch | sdk.tokenLaunch | createTokenInfoAndMetadata(), createLaunchTransaction() |
| Partner | sdk.partner | getPartnerConfig(), getPartnerConfigClaimTransactions() |
| Dexscreener | sdk.dexscreener | checkOrderAvailability(), createOrder() |
PublicKey objects, not raw strings. Every tool handles this conversion internally — you always pass plain Base58 strings.
Zero-Custody Model
BagsSDK MCP never touches your private keys. The architecture ensures:
- Transaction-generating tools (swap, claim, launch, fee config) return unsigned base64-encoded
VersionedTransactionobjects - You sign externally using your browser wallet (Phantom, Solflare, Backpack, Coinbase)
- You broadcast using
bags_send_transactionafter signing, or the signing page handles it automatically
Transaction Flow
text┌──────────────┐ ┌───────────┐ ┌──────────┐ ┌──────────┐
│ AI requests │ -> │ BagsSDK │ -> │ You sign │ -> │ On-chain │
│ bags_swap │ │ returns │ │ with │ │ via │
│ │ │ unsigned │ │ Phantom │ │ send_tx │
│ │ │ base64 tx │ │ │ │ │
└──────────────┘ └───────────┘ └──────────┘ └──────────┘
The Signing Page
For token launches, the server opens a local page on localhost:3141. This page connects directly to your browser wallet extension — the MCP server never sees your keys. Connect your wallet, approve the transactions, and the page broadcasts them to Solana.
bags_agent_wallet_export tool only exports public key information.
Signing Server Hardening
The localhost signing server includes multiple layers of protection:
- High-entropy session IDs — 32-byte
crypto.randomBytes(64 hex chars) instead of UUIDs - CSRF tokens — per-session tokens embedded in the page and validated on every POST
- Origin validation — POST requests from foreign origins are rejected (prevents cross-site attacks)
- SRI integrity hashes — CDN-loaded
@solana/web3.jsverified with SHA-384 subresource integrity - XSS prevention — all dynamic content rendered via
textContent, neverinnerHTML - Race-safe sessions — file-backed session store serialized behind an async mutex
Tiered Caching
The Bags.fm API has a 1,000 requests/hour rate limit. The cache protects against hitting it with five TTL tiers:
| Tier | TTL | What Gets Cached |
|---|---|---|
| Immutable | Forever | Social-to-wallet resolution (never changes) |
| Stable | 10 min | Creators, pool configs, partner configs |
| Moderate | 5 min | Lifetime fees, claim stats, token feed, pools |
| Volatile | 2 min | Claimable positions |
| None | 0 | Quotes, transactions, auth, send-tx |
The cache is in-memory (Map-based) with no external dependencies. Entries auto-expire on read.
Error Handling
Every tool wraps its handler in try/catch and maps HTTP status codes to actionable messages:
| Status | Message |
|---|---|
401 | Check your BAGS_API_KEY. Get one at dev.bags.fm |
429 | Rate limited. BagsSDK caches responses. Retry in 60 seconds. |
404 | Resource not found. Verify addresses and mints are correct. |
| Connection error | Cannot reach Bags API. Check network and BAGS_API_BASE. |
Errors are returned as MCP isError: true responses so the AI client can explain what went wrong and suggest fixes.
Trading Tools
bags_quote
Get a swap quote without creating a transaction. Read-only price check.
bags_swap
Create an unsigned swap transaction. Gets a quote first, then builds the transaction.
So11111111111111111111111111111111111111112 is used automatically as the counterpart for all swaps.
Launch Tools
bags_launch_feed
Fetch the live token launch feed. Cached for 5 minutes.
bags_create_token_info
Step 1: Upload token metadata to IPFS via Bags API.
bags_create_launch_tx
Step 3: Build the launch transaction (after fee config is created).
bags_launch_token
Composed: Full launch flow in one call — metadata + fee config + launch transaction.
Fee Tools
bags_resolve_wallet
Resolve a social media handle to a Bags.fm Solana wallet. Cached permanently.
bags_resolve_wallets_bulk
Resolve multiple handles at once. Partial failure tolerant.
bags_create_fee_config
Create an on-chain fee share configuration. Validates BPS sum to 10000.
bags_compose_fee_config
Build and validate a fee config without submitting. Preview mode.
bags_fee_admin_list
List all fee share configs you administer. Cached 10 minutes.
bags_fee_admin_transfer
Transfer fee share admin rights to another wallet. Irreversible.
bags_fee_admin_update
Update claimers and BPS on an existing fee config.
bags_claim_events
Fetch claim event history. Supports pagination and time-range queries.
Claiming Tools
bags_claimable_positions
View all your unclaimed fee positions with SOL amounts. Cached 2 minutes.
bags_claim_fees
Claim fees for a specific token. May return multiple transactions.
bags_claim_all_fees
Composed: Claim all positions above a dust threshold in one call.
Partner Tools
bags_partner_stats
View your partner fee earnings. Cached 10 minutes.
bags_partner_claim
Claim accumulated partner fees.
bags_partner_config
Create or retrieve a partner configuration.
Dexscreener Tools
bags_dexscreener_check
Check if Dexscreener profile boosting is available for a token.
bags_dexscreener_order
Create a Dexscreener boost order. Must pay before activation.
bags_dexscreener_payment
Confirm payment after signing the payment transaction.
Agent Auth Tools
bags_agent_auth_init
Step 1: Start the agent authentication flow.
bags_agent_auth_login
Step 2: Complete authentication with verification code.
bags_agent_wallet_list
List all wallets associated with authenticated agent.
bags_agent_wallet_export
Export public key details for a wallet. Never exposes private keys.
bags_agent_keys_list
List all API keys for the authenticated agent.
bags_agent_keys_create
Create a new API key. Shown once — save it immediately.
bags_agent_bootstrap
Composed: Full agent setup — auth, verify, login, wallets, API key.
State Tools
bags_pools
List all active liquidity pools.
bags_pool
Get details for a specific pool — reserves, fee config, migration status.
bags_pool_config_keys
Get Meteora pool config key addresses from fee claimer vaults.
Analytics Tools
bags_token_creators
Get creator info for a token — wallets, social profiles, royalty BPS.
bags_lifetime_fees
Get total lifetime trading fees collected by a token.
bags_claim_stats
Aggregate claim statistics for a wallet or token.
bags_top_tokens
Leaderboard of tokens ranked by lifetime trading fees.
Solana Tools
bags_send_transaction
Broadcast a signed transaction to Solana. The only tool that sends anything on-chain.
bags_wallet_balance
Check SOL balance for any wallet. Direct RPC call, never cached.
bags_token_holdings
List all SPL token holdings for a wallet. Filters to non-zero balances.
Signing Tools
bags_open_signing_page
Open a localhost signing page for arbitrary unsigned transactions. Connects to your browser wallet for approval.
bags_open_launch_page
Open the launch signing page with both fee config and launch transactions pre-loaded. Handles the two-signature flow automatically.
Meta Tools
bags_tool_catalog
Returns a structured catalog of all available tools with descriptions, inputs, and groupings. Useful for discovery and help.
Scout Tools
bags_scout_scan
Run one scout scan cycle. Fetches live headlines from Reddit, Hacker News, and Bags.fm, ranks them by meme potential, and assembles complete launch packages with AI-generated names, tickers, descriptions, and logos. Returns packages for review — does not launch anything.
bags_scout_launch
Launch a token from a scout package. Creates token metadata on IPFS, configures fee sharing, and opens a signing page where you connect your wallet and sign. Accepts a full or modified LaunchPackage from bags_scout_scan.
bags_generate_token_image
Generate a token logo image from a text prompt using fal.ai (Nano Banana Pro) or Replicate (Nano Banana 2). Returns a public image URL ready for use in token launches. Works as a standalone tool outside of scout mode.
Resources
MCP resources provide browsable context that AI clients can read without making a tool call.
| Resource | URI | Type | Description |
|---|---|---|---|
| launch-feed | bags://launches | Static | Live token launch feed, cached 5 min |
| pools | bags://pools | Static | All active liquidity pools, cached 5 min |
| token | bags://token/{mint} | Template | Composite view: pool + creators + lifetime fees |
| portfolio | bags://portfolio/{wallet} | Template | All claimable positions with SOL amounts |
Static resources have a fixed URI. Template resources accept a parameter in the URI path and fetch data dynamically.
Prompts
Prompts are guided workflows that structure multi-tool operations. Select a prompt and the AI receives pre-built instructions for executing a complex multi-step flow.
bags_launch_token
Solo token launch workflow.
bags_launch_team_token
Team launch with multi-party fee splits.
bags_analyze_fees
Fee earnings analysis for a token or wallet.
bags_setup_partner
Partner configuration setup guide.
bags_claim_all
Batch fee claiming with dust threshold.
bags_portfolio_overview
Full portfolio summary — balances, holdings, fees, stats.
bags_getting_started
Interactive onboarding for new users. Shows available capabilities and guides them to a starting point.
bags_create_custom_tool
Scaffold a new MCP tool from a plain-English description. Generates TypeScript tool files using Bags SDK services.
Guide: Check Your Portfolio
The fastest way to see everything about your wallet in one shot.
Step 1 — Check SOL balance
"What's my SOL balance? Wallet: ABC123..."
Tool: bags_wallet_balance
Step 2 — View token holdings
"What tokens do I hold?"
Tool: bags_token_holdings — returns all SPL tokens with non-zero balances.
Step 3 — Check unclaimed fees
"Do I have any unclaimed fees?"
Tool: bags_claimable_positions — shows each position with claimable SOL.
Or use the prompt
Select bags_portfolio_overview and provide your wallet address. It runs all three steps in parallel.
Guide: Claim Your Creator Fees
Every token launched via Bags.fm accumulates trading fees for the creator. Here is how to collect them.
Step 1 — Check what you are owed
"Show my claimable positions for wallet ABC123..."
Tool: bags_claimable_positions — returns each token with unclaimed SOL amount.
Step 2 — Claim fees for one token
"Claim my fees from token XYZ..."
Tool: bags_claim_fees — builds the unsigned transaction and opens a signing page at localhost:3141.
Step 3 — Sign in your browser
Open the signing URL. Connect the same wallet that launched the token (Phantom, Solflare, etc.). Sign the transaction. Your SOL is deposited immediately.
bags_claim_all_fees with an optional dust filter (e.g. skip positions under 0.01 SOL). All claim transactions are batched into a single signing page.
How it works under the hood
The SDK fetches your claimable positions, builds claim transactions via the Bags API, and routes them through the local signing server. Your private key never leaves your wallet — the MCP server only handles unsigned transactions.
Guide: Launch a Token
Step 1 — Prepare metadata
"Create token info: name MOON, symbol $MOON, description 'To the moon', image https://..."
Tool: bags_create_token_info — uploads to IPFS, returns tokenMint and URI.
Step 2 — Open the launch page
"Launch it with 0.1 SOL initial buy, my wallet is ABC123..."
Tool: bags_open_launch_page — opens localhost:3141 with both transactions ready.
Step 3 — Sign in your browser
Connect your wallet on the signing page. Approve the fee config transaction first, then the launch transaction. Your token is live.
bags_launch_token composed tool or prompt to do all steps in a single call.
Guide: Team Token Launch
Step 1 — Resolve all team members
"Resolve these wallets:
- twitter:alice (50%)
- twitter:bob (30%)
- twitter:charlie (20%)"
Tool: bags_resolve_wallets_bulk
Step 2 — Compose fee config
"Compose a team fee split with those percentages"
Tool: bags_compose_fee_config — validates BPS, checks for duplicates, shows preview.
Step 3 — Upload metadata + launch
Same as solo launch — bags_create_token_info then bags_open_launch_page.
Step 4 — Optional: Dexscreener boost
"Check if we can boost this token on Dexscreener"
Tools: bags_dexscreener_check → bags_dexscreener_order → sign → bags_dexscreener_payment
Guide: Analyze a Token
Step 1 — Lifetime fees
"How much in fees has token XYZ generated?"
Tool: bags_lifetime_fees
Step 2 — Creators
"Who are the creators of token XYZ?"
Tool: bags_token_creators
Step 3 — Claim history
"Show recent claim events for token XYZ"
Tool: bags_claim_events
Step 4 — Aggregate stats
"What are the claim stats for this token?"
Tool: bags_claim_stats
Guide: Partner Setup
Step 1 — Create partner config
"Set up a partner config with 25% fee for wallet ABC123"
Tool: bags_partner_config with feeBps: 2500
Step 2 — Share with creators
Give token creators your partner wallet and config address. When they include it in bags_create_fee_config, you earn a cut of trading fees.
Step 3 — Check earnings and claim
"How much have I earned as a partner?"
Tools: bags_partner_stats → bags_partner_claim → sign → bags_send_transaction
Fee Config Composer
The FeeConfigBuilder provides a fluent API for composing fee splits without dealing with raw BPS math.
Fluent API
TypeScriptFeeConfigBuilder.create()
.addRecipient("twitter", "alice", 5000) // 50%
.addRecipient("twitter", "bob", 3000) // 30%
.addDividendsBot(2000) // 20% to holders
.validate() // { valid: true, errors: [] }
Template Presets
| Template | Description | Default Split |
|---|---|---|
soloCreator | 100% to one person | 10000 BPS |
creatorPlusDividends | Creator + DividendsBot | 50/50 |
teamSplit | Even split across members | Auto-calculated |
influencerLaunch | Creator + influencers + dividends | 30% / split / 20% |
dao | DAO treasury + dividends | Configurable |
Validation Rules
- At least 1 recipient, max 100
- All BPS must be positive integers
- BPS must sum to exactly 10000 (100%)
- No duplicate provider:username pairs
- Warns when >15 claimers (needs lookup tables)
Agent Mode
Activated with the --agent flag. Runs autonomous strategies using dual-model AI orchestration.
NOUS_API_KEY (Hermes 4) and ANTHROPIC_API_KEY (Claude Sonnet) in your environment.
Dual-Model Routing
| Model | Handles | Trigger Patterns |
|---|---|---|
| Hermes 4 (fast) | Routine tasks | claim, balance, check, list, monitor, status |
| Claude Sonnet (strategic) | Complex decisions | evaluate, analyze, recommend, optimize, compare, strategy |
Strategies
auto-claim
Checks positions every 5 minutes. Claims fees above 0.01 SOL threshold.
bashbags-sdk-mcp --agent --auto-claim
launch-monitor
Watches the launch feed every 30 seconds. Tracks seen mints. Escalates interesting launches to Sonnet for analysis.
bashbags-sdk-mcp --agent --monitor
scout
A global trend radar that scans live news headlines from across the internet, identifies the most memeable topics, and assembles complete token launch packages. You review the ideas and decide what ships — the agent never launches autonomously.
bashbags-sdk-mcp --agent --scout
How Scout Works
Every scan cycle (default 30 minutes), Scout runs a four-stage pipeline:
| Stage | What Happens | Model |
|---|---|---|
| 1. Gather | Fetches live headlines from Reddit (7 subreddits), Hacker News, and the Bags.fm feed | — |
| 2. Rank | Filters for virality, meme potential, emotional charge, and timeliness | Hermes 4 |
| 3. Create | Generates token name, ticker, description, and logo for each top idea | Sonnet + fal.ai |
| 4. Present | Shows packages to you with launch / edit / skip commands | — |
News Sources
Scout pulls real-time headlines from diverse sources — not just crypto. Any trending topic can become a token:
| Source | Category | Why |
|---|---|---|
| r/worldnews | World events | Breaking geopolitical news, international drama |
| r/news | Breaking news | US and general breaking stories |
| r/politics | Politics | Government moves, elections, policy changes |
| r/memes | Memes | Viral internet culture, trending formats |
| r/technology | Tech | AI announcements, product launches, tech drama |
| r/wallstreetbets | Finance memes | Market sentiment, retail trader culture |
| r/CryptoCurrency | Crypto | Token news, protocol updates, market moves |
| Hacker News | Tech / science | Deep tech, startups, science breakthroughs |
| Bags.fm feed | Platform | Active launches and top tokens on-platform |
FAL_API_KEY (fal.ai) or REPLICATE_API_KEY (Replicate) for auto-generated logos. Without one, packages come without images and you add one before launching.
Scout Configuration
| Env Variable | Default | Description |
|---|---|---|
IMAGE_GEN_PROVIDER | fal | Image provider: fal or replicate |
FAL_API_KEY | — | fal.ai API key (uses Nano Banana Pro for token logo generation) |
REPLICATE_API_KEY | — | Replicate API key (alternative to fal.ai) |
SCOUT_INTERVAL | 1800 | Seconds between scan cycles (set to 60 for testing) |
SCOUT_SOURCES | bags,news | Comma-separated: bags, news |
SCOUT_MAX_IDEAS | 3 | Max launch packages per cycle (1–10) |
Scout Setup Guide
- Add your image gen key to
.env:FAL_API_KEY=your-key - Run
bags-sdk-mcp --agent --scout - Wait for the first scan (or set
SCOUT_INTERVAL=60for testing) - Review the packages — each shows name, ticker, image status, fee split, and source
- Type
launch 1to execute,edit 1to modify, orskipto wait - Sign the returned transactions in your wallet
Interactive Commands
| Command | Action |
|---|---|
launch N | Launch package N — creates token metadata, fee config, and returns unsigned transactions |
edit N | Enter edit mode for package N — modify name, symbol, or description inline |
details N | Show full package details including image prompt and reasoning |
skip | Skip all packages and wait for next cycle |
done | Exit edit mode and show updated packages |
Using Scout via MCP (Claude Desktop / Cursor)
When connected as an MCP server, Scout exposes three tools you can invoke with natural language:
- "Scan for trending token ideas" → calls
bags_scout_scan— returns launch packages from live headlines - "Launch the first one with my wallet" → calls
bags_scout_launch— creates token info, fee config, and opens signing page - "Generate a token logo for a space cat coin" → calls
bags_generate_token_image— returns an image URL via fal.ai or Replicate
Example Flow
text# Scout finds trending headlines across Reddit, HN, and Bags.fm
# Hermes ranks them by meme potential and timeliness
# Sonnet generates creative token packages
# fal.ai generates logos
┌──────────────────────────────────────┐
│ SCOUT FOUND 2 IDEAS │
├──────────────────────────────────────┤
│ 1. LNGBOOM ($LNG) │
│ "Qatar's LNG plant got hit, │
│ energy markets in shambles" │
│ Image: ✓ generated │
│ Source: reddit/world news │
│ │
│ 2. NOTOURWAR ($NOW) │
│ "Europe tells Trump: not our │
│ war, handle it yourself" │
│ Image: ✓ generated │
│ Source: reddit/world news │
├──────────────────────────────────────┤
│ launch 1 — launch LNGBOOM │
│ edit 1 — modify before launch │
│ skip — wait for next cycle │
└──────────────────────────────────────┘
Combined
bashbags-sdk-mcp --agent --scout --auto-claim --monitor
HTTP Transport
For remote connections and non-desktop integrations, use the Streamable HTTP transport.
bashbags-sdk-mcp --http # Port 3000
bags-sdk-mcp --http --port=8080 # Custom port
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /mcp | MCP protocol endpoint |
GET | /health | Health check |
Each request creates a fresh server + transport pair (stateless), making it suitable for serverless deployments.
CLI Reference
Setup
bashbags-sdk-mcp --setup # Interactive installer for Claude Desktop, Cursor, etc.
bags-sdk-mcp --uninstall # Remove from all detected MCP client configs
# Claude Code (one command):
claude mcp add bags-sdk-mcp -e BAGS_API_KEY=xxx -- npx bags-sdk-mcp
Server
bashbags-sdk-mcp # Start stdio server (default)
bags-sdk-mcp --http # Start HTTP server on port 3000
bags-sdk-mcp --http --port=8080 # HTTP on custom port
Agent
bashbags-sdk-mcp --agent --auto-claim # Claim fees above threshold every 5 min
bags-sdk-mcp --agent --monitor # Watch launches, flag interesting ones
bags-sdk-mcp --agent --scout # Scan trends, propose token launches
bags-sdk-mcp --agent --scout --auto-claim --monitor # All strategies
One-Shot Tools
bashbags-sdk-mcp --fee-optimize # Analyze fee configs, suggest improvements
bags-sdk-mcp --rebalance # Analyze positions, recommend claim strategy
Diagnostics
bashbags-sdk-mcp --doctor # Check everything: env, API, RPC, configs, ports
bags-sdk-mcp --info # Show current config and capabilities (no network)
bags-sdk-mcp --whoami # Test API key and show wallet stats
bags-sdk-mcp --test-key # Validate API key only
bags-sdk-mcp --version # Print version
bags-sdk-mcp --clear-sessions # Wipe expired signing sessions
Troubleshooting
If something isn't working, start with --doctor. It checks your env vars, API key, RPC connectivity, MCP client configs, signing port, and sessions — then tells you exactly what's wrong.
| Problem | Fix |
|---|---|
| BAGS_API_KEY is missing | Run npx bags-sdk-mcp --setup or set the key in your MCP config |
| Key validation fails | Get a new key at dev.bags.fm, then npx bags-sdk-mcp --test-key |
| Signing page won't load | Port 3141 may be in use — --doctor will check |
| Stale signing sessions | Run npx bags-sdk-mcp --clear-sessions |
| Agent mode crashes | Check NOUS_API_KEY and ANTHROPIC_API_KEY — --doctor flags these |
Technology Stack
| Layer | Choice | Version |
|---|---|---|
| Language | TypeScript (strict mode) | 5.8+ |
| MCP SDK | @modelcontextprotocol/sdk | ^1.12.0 |
| Bags SDK | @bagsfm/bags-sdk | ^1.2.7 |
| Solana | @solana/web3.js | ^1.95.0 |
| Schema | zod | ^3.25.0 |
| HTTP | express | ^4.21.0 |
| Test | vitest | ^3.0.0 |
Writing New Tools
Want to extend the MCP server with your own tools? Here's how.
File Structure
Each tool lives in src/tools/{domain}/ with its own file. One tool per file, one responsibility per tool.
textsrc/tools/
├── trading/
│ ├── quote.ts # bags_quote
│ └── swap.ts # bags_swap
├── your-domain/
│ └── your-tool.ts # bags_your_tool
└── _registry.ts # imports all tools
Anatomy of a Tool
Every tool has four parts: a name, a description, a Zod input schema, and a handler function.
TypeScriptimport { z } from "zod";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { getClient } from "../../client/bags-sdk-wrapper.js";
import { cache, CacheTier } from "../../client/cache.js";
/** Register the example tool on the MCP server. */
export function registerMyTool(server: McpServer): void {
server.tool(
"bags_my_tool",
"One-sentence description of what this tool does.",
{
tokenMint: z.string().describe("Base58 token mint address"),
limit: z.number().optional().describe("Max results to return"),
},
async ({ tokenMint, limit }) => {
try {
const cacheKey = `my-tool:${tokenMint}`;
const cached = cache.get(cacheKey);
if (cached) return cached;
const sdk = getClient();
const result = await sdk.state.getSomeData(tokenMint);
const response = {
content: [{
type: "text" as const,
text: JSON.stringify(result, null, 2),
}],
};
cache.set(cacheKey, response, CacheTier.MODERATE);
return response;
} catch (error: unknown) {
const message = error instanceof Error
? error.message
: "Unknown error";
return {
content: [{ type: "text" as const, text: message }],
isError: true,
};
}
}
);
}
Registration
Import your tool in src/tools/_registry.ts and call the register function:
TypeScriptimport { registerMyTool } from "./your-domain/your-tool.js";
export function registerAllTools(server: McpServer): void {
// ... existing tools ...
registerMyTool(server);
}
Cache Tier Selection
| Use This Tier | When |
|---|---|
CacheTier.IMMUTABLE | Data that never changes (wallet resolution) |
CacheTier.STABLE | Changes rarely (creator info, configs) |
CacheTier.MODERATE | Changes occasionally (fee stats, pools) |
CacheTier.VOLATILE | Changes frequently (positions) |
| No cache | Real-time data (quotes, transactions) |
Testing
bashnpm run build # compile your changes
npm run inspect # open MCP Inspector in browser
npm test # run test suite
The MCP Inspector lets you call your tool interactively and see the raw response.
Guidelines
- Use the SDK wrapper (
getClient()) when a typed method exists - Fall back to the REST client (
bags-rest.ts) for endpoints not covered by the SDK - Always return
isError: trueon failures so the AI can explain what went wrong - Cache appropriately — never cache transactions or quotes
- Keep descriptions concise — the AI reads them to decide which tool to call
Environment Variables
Variables are loaded from .env automatically.
| Variable | Required | Default |
|---|---|---|
BAGS_API_KEY | Yes | — |
SOLANA_RPC_URL | No | mainnet-beta |
BAGS_API_BASE | No | https://public-api-v2.bags.fm/api/v1 |
NOUS_API_KEY | Agent mode | — |
ANTHROPIC_API_KEY | Agent mode | — |
AGENT_WALLET_PUBKEY | Agent mode | — |
FAQ
Is this safe? Can it steal my funds?
No. The server uses a zero-custody model. It never sees your private keys. Every transaction is returned unsigned — you sign in your own browser wallet (Phantom, Solflare, Backpack, Coinbase). Keys never leave your device.
What wallets are supported?
Any Solana wallet with a browser extension: Phantom, Solflare, Backpack, and Coinbase Wallet. The signing page auto-detects installed wallets.
What's the API rate limit?
1,000 requests per hour. The built-in tiered cache keeps you well under this limit during normal use. Real-time data (quotes, transactions) bypasses the cache but these are infrequent.
Can I run this headless / on a server?
Yes. Use HTTP transport mode: bags-sdk-mcp --http. It exposes a stateless MCP endpoint suitable for serverless or load-balanced deployments.
Does this work with Cursor / other MCP clients?
Yes. Any MCP-compatible client works — Claude Desktop, Claude Code, Cursor, or custom agents built with the MCP SDK. Just add the config block to your client's config file.
How do I get an API key?
Go to dev.bags.fm, sign in, and create a key. Each account can create up to 10 keys.
What's the signing page?
A lightweight local web server on localhost:3141 that the SDK spins up when you need to sign transactions. It connects directly to your browser wallet extension — the MCP server is not involved in signing. The page shows transaction details and handles the approve/reject flow.
Why two signatures for a token launch?
Launching a token on Bags.fm requires two on-chain transactions: (1) creating the fee share configuration, and (2) the actual token launch. The signing page handles both in sequence — approve the first, then approve the second.
Can I use a custom RPC endpoint?
Yes. Set SOLANA_RPC_URL in your environment or .env file. Helius and other premium RPC providers are recommended for production use.