Factor MCP Server
OfficialProvides RPC access to supported EVM chains via an Alchemy API key, enabling vault reads, transaction simulation/execution, and other on-chain interactions through Alchemy endpoints.
Supports interacting with Factor Protocol vaults on Ethereum Mainnet, including vault creation and management, deposits and withdrawals, strategy execution, and related DeFi operations.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Factor MCP Server
An MCP (Model Context Protocol) server that enables AI tools to interact with Factor Protocol vaults on EVM chains.
Features
68 MCP Tools for complete vault management
Multi-chain Support: Arbitrum One, Base, Ethereum Mainnet
Secure Wallet Management: Foundry Keystore (Web3 V3) + AES-256-GCM encryption
Simulation Mode: Preview transactions before execution
Strategy Building: Compose DeFi strategies using building blocks
Foundry Integration: Fork simulation, error decoding, forge scripts
Related MCP server: Base MCP Server
Operating Modes
stdio (standard MCP)
The default mode. The server runs as a local process, communicates over stdin/stdout, and maintains global state (active chain, wallet, environment) across tool calls. Use factor_set_chain to switch chains and factor_wallet_setup to configure a wallet.
Stateless (for MCP Gateway integration)
Designed for multi-tenant gateways where many users share one server process. No global state is mutated -- each tool call carries its own chainId and environment parameters.
Enable with the environment variable:
STATELESS_MODE=true node dist/index.jsOr set STATELESS_MODE=true in the process environment.
Key differences in stateless mode:
Behavior | stdio mode | Stateless mode |
Chain selection |
|
|
Environment | Set once via config/env var |
|
Wallet | Required for write ops | Not needed -- |
Gas estimation | Runs against RPC | Skipped (returns zeroed estimate) |
Allowance check | Checked before vault creation | Skipped (sponsorship handles approval) |
Client caching | Singleton | Fresh client per request (concurrent safety) |
Simulation mode | Configurable | Always true |
How it works internally:
ConfigManager(insrc/config/index.ts) uses Node.jsAsyncLocalStorageto store per-request context (chainId,environment).In
server.ts, eachCallToolRequestextractschainIdandenvironmentfrom tool arguments and wraps the handler inconfigManager.runWithContext(ctx, execute).All config getters (
getChain(),getChainId(),getRpcUrl(),getEnvironment()) read fromAsyncLocalStoragefirst, falling back to global config only in stdio mode.State-mutating setters (
setChain(),setRpcUrl()) throw in stateless mode to prevent global mutation.sendTransaction()insrc/wallet/signer.tsreturns acalldataobject ({ to, data, value, chainId }) instead of signing and broadcasting.factor_create_vaultaccepts anownerAddressparameter (required in stateless) to set the vault owner without needing a local wallet. PassfeeReceiverAddresswhen fee revenue must go to a different address.getClient()insrc/sdk/client.tscreates a freshPublicClientper call in stateless mode instead of using the global cache, ensuring concurrent requests with different chains do not collide.
Quick Start
One-Line Install
curl -sSL https://raw.githubusercontent.com/FactorDAO/factor-mcp/main/install.sh | bashThis will:
Install Rust (if not present)
Install Foundry (cast, anvil, forge)
Clone and build Factor MCP
Create
factor-mcpcommand
Manual Installation
git clone https://github.com/FactorDAO/factor-mcp.git
cd factor-mcp
npm install
npm run buildConfiguration
The server uses JSON configuration stored at ~/.factor-mcp/config.json:
{
"alchemyApiKey": "your_api_key",
"defaultChain": "ARBITRUM_ONE",
"simulationMode": false,
"logLevel": "info",
"activeWallet": "default"
}Environment variables can override JSON config:
ALCHEMY_API_KEY- Alchemy API key for RPC accessDEFAULT_CHAIN- Default chain (ARBITRUM_ONE, BASE, MAINNET)STATELESS_MODE- Set totruefor stateless/gateway mode (per-requestchainIdandenvironment)FACTOR_ENVIRONMENT-production,staging, ortestingSIMULATION_MODE- Set totruefor dry-run modeLOG_LEVEL- Logging level (debug, info, warn, error)FACTOR_ARTIFACTS_DIR- Persist generated forge scripts to this directory (useful in Docker/ephemeral environments)
Running
# Direct execution
npm start
# Or with environment variables
ALCHEMY_API_KEY=xxx npm startClaude Code Integration
Add to your Claude Code config (~/.config/claude-code/config.json or MCP settings):
{
"mcpServers": {
"factor": {
"command": "node",
"args": ["/path/to/factor-mcp/dist/index.js"],
"env": {
"ALCHEMY_API_KEY": "your_api_key"
}
}
}
}Tools Reference
Configuration (5 tools)
Tool | Description |
| Set active chain (ARBITRUM_ONE, BASE, MAINNET) |
| Configure custom RPC endpoint |
| Get current configuration |
| Import/generate wallet with optional encryption |
| Get SDK address book (Pro adapters) for current chain |
Vault Operations (14 tools)
Tool | Description |
| Get ready-to-use vault params (call first when creating vaults) |
| Deploy new Studio Pro vault |
| List vaults owned by an address |
| Get detailed vault information |
| Get user's shares, total supply, price per share |
| Get vault execution history with decoded calls |
| Preview deposit (read-only) |
| Execute deposit (auto-approves tokens) |
| Preview withdrawal (read-only) |
| Execute withdrawal (redeem shares) |
| Execute DeFi strategies as vault manager |
| Get whitelisted assets/adapters from factory |
| Validate vault config before deployment |
| Add a manager adapter to a vault |
Vault Management (12 tools)
Tool | Description |
| Set deposit fee (basis points) |
| Set withdrawal fee (basis points) |
| Set performance fee (basis points) |
| Set annual management fee (basis points) |
| Charge accrued performance fee |
| Set fee receiver address |
| Set maximum deposit cap |
| Set maximum debt ratio |
| Set price deviation tolerance |
| Add manager address |
| Remove manager address |
| Set risk manager address |
Lending Operations (4 tools)
Tool | Description |
| Supply assets to Aave, Compound V3, Morpho, Silo V2 |
| Withdraw supplied assets |
| Borrow assets against collateral |
| Repay borrowed assets |
Swap Operations (4 tools)
Tool | Description |
| Uniswap V3 exact input swaps (specify how much to spend) |
| Uniswap V3 exact output swaps (specify how much to receive) |
| OpenOcean DEX aggregator swaps |
| Pendle PT/YT token swaps |
LP Operations (4 tools)
Tool | Description |
| Create concentrated liquidity position |
| Add liquidity to existing position |
| Remove liquidity from position |
| Collect accumulated trading fees |
Yield Operations (1 tool)
Tool | Description |
| Pendle LP (add/remove liquidity, collect fees) |
Flash Loan (1 tool)
Tool | Description |
| Execute flash loan strategies (Aave, Morpho) |
Token & Registry (3 tools)
Tool | Description |
| Approve ERC20 token for spending |
| Look up lending tokens (aTokens, debt tokens) |
| Add asset/debt token to vault with accounting |
Strategy Building (1 tool)
Tool | Description |
| List available protocol adapters (30+) |
Transaction Tools (2 tools)
Tool | Description |
| Preview tx with gas estimate |
| Check tx status by hash |
Profile & Strategy (6 tools)
Tool | Description |
| Save a user profile (requires wallet signature) |
| Get a user profile by address (read-only) |
| Save or update a vault strategy (requires wallet signature) |
| Delete a saved strategy (requires wallet signature) |
| Get a strategy by hash (read-only) |
| Get all strategies for an owner on a chain (read-only) |
Foundry Tools (5 tools)
Tool | Description |
| Check Foundry installation |
| Execute read-only contract calls |
| Simulate on forked network |
| Decode contract error data |
| Run Solidity forge scripts |
Security
Wallet Storage
Wallets support two backends:
Factor-MCP (default):
~/.factor-mcp/wallets/— AES-256-GCM encryption, PBKDF2 key derivation (100k iterations)Foundry Keystore:
~/.foundry/keystores/— Web3 Secret Storage V3 format, compatible with cast/geth
Best Practices
Always use encryption for production wallets
Use simulation mode for testing (
simulationMode: true)Never commit wallet files or API keys
Docker Deployment
# Build image
docker build -t factor-mcp .
# Run with docker-compose
docker-compose up -dDevelopment
# Install dependencies
npm install
# Type checking
npm run typecheck
# Build
npm run build
# Run in dev mode
npm run dev
# Run tests
npm testSDK Coverage Roadmap
This roadmap tracks the MCP server's coverage of the @factordao/sdk-studio package. Items marked [x] are implemented in the MCP, items marked [ ] are SDK features not yet exposed.
Configuration & Wallet
Set active chain (ARBITRUM_ONE, BASE, MAINNET)
Set custom RPC endpoint
Get current config (chain, RPC, wallet, simulation mode)
Wallet import from private key
Wallet generation (new random)
Foundry Keystore storage (Web3 V3 format)
Factor-MCP encrypted storage (AES-256-GCM)
Use existing Foundry keystore
Get SDK address book (Pro adapter addresses)
Vault Creation & Templates
Deploy new Factor Pro vault (
factor_create_vault)Vault templates with ready-to-use params (
factor_vault_templates)Lending-ready vault templates (Aave preset)
Lending-ready vault templates (Compound V3 preset)
Lending-ready vault templates (Morpho preset)
Auto-detect accounting adapters from factory
Validate vault config before deployment (
factor_validate_vault_config)Get whitelisted factory addresses (
factor_get_factory_addresses)Immutable vault option
Configurable fees, caps, debt ratio, cooldown, upgradeability
Vault Queries
Get owned vaults (
factor_get_owned_vaults)Get vault info — assets, fees, managers, adapters (
factor_get_vault_info)Get user shares, total supply, price per share (
factor_get_shares)Get execution history with decoded calls (
factor_get_executions)Preview deposit — expected shares (
factor_preview_deposit)Preview withdrawal — expected assets (
factor_preview_withdraw)Check if asset is valid deposit asset (
isDepositAsset)Check if asset is valid withdraw asset (
isWithdrawAsset)Get asset accounting adapter (
getAssetAccounting)Get debt accounting adapter (
getDebtAccounting)Estimate raw withdraw expected amount (
estimateRawWithdrawExpectedAmount)USD balance breakdown via Alchemy (
balanceUsd)
Vault Deposit & Withdrawal
Deposit ERC20 token (
factor_deposit)Withdraw / redeem shares (
factor_withdraw)Deposit native token — ETH (
depositNative)Deposit and execute strategy in one tx (
depositAssetAndExecute)Raw withdraw with execution blocks (
rawWithdraw)
Vault Fee Management
Set deposit fee (
factor_set_deposit_fee)Set withdraw fee (
factor_set_withdraw_fee)Set performance fee (
factor_set_performance_fee)Set management fee (
factor_set_management_fee)Charge performance fee (
factor_charge_performance_fee)Set fee receiver (
factor_set_fee_receiver)
Vault Risk & Access Management
Set max deposit cap (
factor_set_max_cap)Set max debt ratio (
factor_set_max_debt_ratio)Set price deviation allowance (
factor_set_price_deviation_allowance)Add vault manager (
factor_add_vault_manager)Remove vault manager (
factor_remove_vault_manager)Set risk manager (
factor_set_risk_manager)
Vault Strategy Configuration
Set public strategy (
setPublicStrategy)Remove public strategy (
removePublicStrategy)Execute public strategy (
executePublicStrategy)Set deposit strategy (
setDepositStrategy)Remove deposit strategy (
removeDepositStrategy)
Vault Simulation
Simulate deposit (
simulateDeposit)Simulate charge performance fee (
simulateChargePerformanceFee)
Token & Approval
ERC20 token approval (
factor_give_approval)Get lending tokens — aTokens, debt tokens, underlying (
factor_get_lending_tokens)Add asset/debt token to vault (
factor_add_vault_token)ERC2612 permit / gasless approval (
permitadapter)
Lending — Aave V3
Supply / supply all / supply by percentage
Withdraw / withdraw all
Borrow
Repay / repay all
Lending — Compound V3
Supply / supply all
Withdraw / withdraw all
Borrow
Repay / repay all
Claim rewards (
claimRewards)
Lending — Morpho
Supply (lending)
Supply as collateral
Withdraw (lending + collateral)
Borrow
Repay / repay all
Lending — Silo V2
Supply
Withdraw
Borrow
Repay
DEX — Uniswap V3
Exact input single swap (
factor_swap)Swap all balance
Swap by percentage
Configurable fee tiers (100, 500, 3000, 10000)
Configurable slippage
Exact output single swap (
factor_swap_exact_output)Exact output single with full balance (
factor_swap_exact_outputwith amountInMax "all")
DEX — OpenOcean
Aggregated swap (
factor_swap_openocean)
DEX — Pendle PT/YT
Token to PT swap
Token to YT swap
PT to token swap
YT to token swap
DEX — Aqua
Aqua DEX swap (Base)
LP — Uniswap V3
Create concentrated liquidity position
Add liquidity to existing position
Remove liquidity (amount or "all")
Collect accumulated fees
Remove liquidity by percentage (
removeByPercentage)
LP — Camelot V3
Create concentrated liquidity position
Add liquidity
Remove liquidity
Collect fees
Remove liquidity by percentage (
removeByPercentage)
LP — Aerodrome
Create concentrated liquidity position
Add liquidity
Remove liquidity
Collect fees
Yield — Pendle LP
Add liquidity to Pendle market
Remove liquidity
Collect fees/rewards
Flash Loans
Aave flash loan with inner strategy steps
Morpho flash loan with inner strategy steps
Balancer flash loan (
balancerFL)
Strategy Builder
Execute strategy via
executeByManagerList available adapters (
factor_list_adapters)Save strategy to Stats API (
factor_save_strategy)Delete strategy from Stats API (
factor_delete_strategy)Get strategy by hash (
factor_get_strategy)Get strategies by owner (
factor_get_strategies)Save profile to Stats API (
factor_save_profile)Get profile from Stats API (
factor_get_profile)Export strategy as calldata (
export)Export strategy as JSON (
exportToJson)Clone strategy (
clone)Debug strategy step-by-step (
debugFromBlocks)Estimate user impact (
estimate/estimateFromBlocks)Strategy summary (
summary)Guess token state changes (
guessTokenState)
Utility Adapters
Transfer tokens between addresses (
transferadapter)Refund dust amounts (
refundadapter)Native token wrap/unwrap (
nativeadapter)ERC721 / NFT operations (
erc721adapter)Leverage vault operations (
leverageVaultadapter)Leverage strategy building (
leverageStrategyadapter)Deposit policy management (
depositPolicyadapter)Gelato automation setup (
gelatoadapter)Chainlink direct price feed queries (
chainlinkadapter)
Adapter Discovery & Metadata
List adapters by chain (
factor_list_adapters)Get user portfolio info across adapters (
getUserInfo)Get markets for building block / protocol (
getMarkets)Get markets by input token (
getMarketByInToken)Get protocols by input token (
getProtocolsByInToken)Get supported input tokens (
getInTokens)Get adapter metadata (
getMetadata/getMetadataByBuildingBlock)Get all building block types (
getBuildingBlocks)
Boost System
Add tokens to boost whitelist (
addBoostTokenWhitelist)Remove tokens from boost whitelist (
removeBoostTokenWhitelist)Deposit vault reward (
depositRewardForVaultBN)Redeem boost rewards (
redeemBoostRewards)Redeem all boost rewards (
redeemBoostRewardAll)Get boost reward tokens (
getBoostRewardTokens)Get earned boost tokens by user (
boostEarnedTokensByUser)Get reward data (
rewardData)Get reward for duration (
getRewardForDuration)
Scale System
Get Scale vaults (
getVaults)Get Scale vault details (
getVaultDetail)Get user Scale positions (
getUserVaults)Get user active balance (
activeBalance)Get total active supply (
totalActiveSupply)Get Scale reward tokens (
getScaleRewardTokens)Redeem Scale rewards (
redeemScaleRewards)Redeem boost + Scale rewards combined (
redeemBoostAndScaleRewards)Vote on gauge (
vote)Remove vote (
unvote)Get user / vault votes
Claim Scale rewards (
claimRewards)Get Scale market data (
getMarketData)Get historical data (
getHistoricalData)
Bribe System
Create bribe (
addBribe)Claim bribe (
claimBribe)Get bribe info (
getBribe)Get all bribes (
getAllBribes)
Transaction & Debugging
Preview transaction with gas estimate (
factor_preview_transaction)Check transaction status (
factor_get_transaction_status)Check Foundry installation (
factor_check_foundry)Read-only contract calls via
cast(factor_cast_call)Simulate on forked network via
anvil(factor_simulate_transaction)Decode contract errors (
factor_decode_error)Run Solidity forge scripts (
factor_run_forge_script)Balance overrides for simulation
Simulation hints with auto-generated Forge scripts
Pro Adapter Availability
Only _pro adapters are used by the MCP server. Adapters without any deployment are excluded from the roadmap.
Lending
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Aave | ✅ | ✅ | ✅ | ✅ |
Compound V3 | ✅ | ✅ | ✅ | ✅ |
Compound V3 Market | ✅ | ✅ | ✅ | ✅ |
Morpho | - | - | ✅ | ✅ |
Morpho Market | - | - | ✅ | ✅ |
Silo V1 | ✅ | ✅ | - | ✅ |
Silo V2 | - | ✅ | - | - |
Silo V2 Market | - | ✅ | - | - |
DEX
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Uniswap | ✅ | ✅ | ✅ | ✅ |
OpenOcean | ✅ | ✅ | ✅ | ✅ |
Pendle PY (PT/YT swaps) | ✅ | ✅ | ✅ | ✅ |
Pendle PY Market | ✅ | ✅ | ✅ | ✅ |
Aqua | - | - | - | ✅ |
LP
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Uniswap V3 LP | - | ✅ | - | ✅ |
Camelot V3 LP | - | ✅ | - | - |
Aerodrome LP | - | - | - | ✅ |
Yield
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Pendle | ✅ | ✅ | - | ✅ |
Flash Loans
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Balancer FL | ✅ | ✅ | ✅ | ✅ |
Morpho FL | - | - | - | ✅ |
Accounting
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Chainlink Accounting | ✅ | ✅ | ✅ | ✅ |
Chainlink Pegged Accounting | ✅ | ✅ | ✅ | ✅ |
Aave Accounting | ✅ | ✅ | ✅ | ✅ |
Pendle Accounting | - | ✅ | - | ✅ |
Pendle PY Accounting | ✅ | - | ✅ | - |
Compound V3 Collateral Accounting | ✅ | ✅ | - | ✅ |
Compound V3 Debt Accounting | ✅ | ✅ | - | ✅ |
Silo V2 Collateral Accounting | - | ✅ | - | - |
Silo V2 Debt Accounting | - | ✅ | - | - |
Infrastructure
Adapter | Arb Prod | Arb Test | Base Prod | Base Test |
Adapter Management | ✅ | ✅ | ✅ | ✅ |
Asset/Debt | ✅ | ✅ | ✅ | ✅ |
Deposit Policy | ✅ | - | - | ✅ |
Gelato | ✅ | ✅ | ✅ | ✅ |
Boost | ✅ | ✅ | ✅ | ✅ |
Note: Ethereum Mainnet has no pro adapters deployed (only factory + Chainlink accounting in testing).
Coverage Summary
Category | Implemented | Total | Coverage |
Configuration & Wallet | 9 | 9 | 100% |
Vault Creation & Templates | 10 | 10 | 100% |
Vault Queries | 6 | 12 | 50% |
Vault Deposit & Withdrawal | 2 | 5 | 40% |
Vault Fee Management | 6 | 6 | 100% |
Vault Risk & Access | 6 | 6 | 100% |
Vault Strategy Config | 0 | 5 | 0% |
Vault Simulation | 0 | 2 | 0% |
Token & Approval | 3 | 4 | 75% |
Lending (Aave, Compound, Morpho, Silo) | 16 | 17 | 94% |
DEX Swaps | 12 | 13 | 92% |
LP Operations | 12 | 14 | 86% |
Yield (Pendle) | 3 | 3 | 100% |
Flash Loans | 2 | 3 | 67% |
Strategy Builder | 8 | 14 | 57% |
Utility Adapters | 0 | 9 | 0% |
Adapter Discovery | 1 | 8 | 13% |
Boost System | 0 | 9 | 0% |
Scale System | 0 | 14 | 0% |
Bribe System | 0 | 4 | 0% |
Transaction & Debugging | 9 | 9 | 100% |
TOTAL | ~99 | ~176 | ~56% |
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Non-custodial DeFi for AI agents: swaps, concentrated liquidity (V3/V4) zaps + ranges, 5 EVM chains
Non-custodial DeFi tools for AI agents on Solana: swaps, perps, lending, staking, equities.
Non-custodial USDC yield vaults on Base mainnet with 9 MCP tools for AI agent treasury.
Agentic AI runtime: persistent memory, vault, autonomous agents, deep research, DeFi execution.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI applications to interact with the Base blockchain network, allowing wallet management, smart contract deployment, token transfers, NFT operations, DeFi interactions with Morpho vaults, and onramping funds via Coinbase.26 npm-
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI applications to interact with the Base blockchain network and Coinbase API, supporting wallet operations, smart contract deployment, token transfers, NFT management, DeFi lending through Morpho vaults, and onramp functionality.26 npm-
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI applications to interact with the Base Network and Coinbase API for onchain operations including wallet management, token transfers, smart contract deployment, NFT operations, DeFi lending through Morpho vaults, and onramping funds.26 npm-
- AlicenseAqualityBmaintenanceDeFi execution and agent-to-agent economy tools for AI agents — swaps, yield, transfers, policy enforcement, trust scoring, A2A jobs, and P\&L across Ethereum, Base, Arbitrum, and Polygon.311Apache 2.0