Folyo for AI agents
Folyo lets you connect an AI agent to your account. It can read your accounts, holdings, positions and watchlists, and, if you allow it, size orders and send them after you say OK in the chat. Nothing reaches your broker without your OK.
Orders by agents is off until you turn it on. Turn it on in Settings › Account › Connected agents, and give the agent the Orders permission when you connect it. Until then an agent can only read and propose.
What an agent can read
Only what you allowed it to read. An AI app sees only the accounts you picked when you connected it.
- Accounts. Your broker account labels and whether each connection is working. Never your broker credentials or tokens.
- Holdings. Equity holdings across your brokers, MTF included, with prices, value, P&L and the time each figure is from.
- Positions. Positions and broker-reported P&L, including closed positions where the broker returns them.
- Portfolio summary. Totals and allocation in INR. When an account or a price is missing, the agent is told the total is partial.
- Duplicates. Stocks you hold in more than one account, with the quantity in each.
- Watchlists. Watchlist names and symbols. Not your private notes.
- Proposals. The orders it prepared and what happened to them.
- Orders and funds. Today’s orders and their status, and the free balance and margin on each account. Read only.
- Plan levels. The target and stop you set on each holding.
- RTGTs and drawings. Your RTGTs and your own chart drawings. The agent never changes them.
- Prices. The last price and daily candles Folyo has stored, one stock at a time. Not a live feed.
Folyo lets an agent add trade ideas to your chart (see Ideas). With your permission it can also add and remove stocks in your watchlists.
Ideas
An idea is a stock and what the agent drew on its chart. The stock joins your Ideas watchlist, an ordinary watchlist. The drawings show on that idea’s own chart layout in Folyo and Trace, marked Agent, never among your own drawings or RTGTs.
- Drawings. Up to 50: price levels, trend lines, boxes, parallel channels, markers and text. A marker sits on a price, or on a bar’s high or low, as a triangle or a circle.
- Moving averages. Up to six SMA or EMA lines on the idea’s layout. The agent can send some hidden: they wait in the chart legend until you turn them on.
- Relative volume. The legend can show the last bar’s volume against its average over the previous bars (20 by default).
- Where it came from. A link to the source, a title and a short note. Folyo copies no images.
- Sent twice. The same idea sent again is the same idea, not a second copy. An agent changes or deletes only the ideas it sent.
- Refused. If something in an idea is wrong, Folyo refuses it whole and tells the agent every problem at once, so it can fix and resend.
How orders work
- The agent sizes the order. It prepares a LIMIT order, or a cancel of an open order, on accounts you allowed. Folyo runs the order ticket’s checks and gives the agent the ticket. Nothing is sent to your broker.
- You say OK in the chat. The agent shows you the ticket in its own chat: stock, side, quantity per account, limit price and checks. Say OK, or ask it to change or drop the order.
- The agent sends it. After your OK it sends that exact ticket. Folyo runs the checks again and sends it the same way the order ticket does: it is your order, as if you placed it from the ticket.
- Five minutes. A ticket not sent within 5 minutes expires. Ask the agent to prepare it again.
Your OK is the consent
Folyo lets an agent send only when Orders by agents is on and you gave that agent the Orders permission. There is no separate approve page: the agent sends only the ticket you said OK to, inside your caps unless you chose No caps, and every other check still runs. ChatGPT never gets it.
Limits
- LIMIT only. No MARKET orders. Day validity. The limit price must sit within 20% of the last close Folyo has for the stock.
- Equity cash. NSE and BSE. CNC delivery, MIS intraday or MTF. No futures, options, commodities or currency.
- Exits. A SELL exits shares the account already holds. If the holding changed since the proposal, or an exit is already working, it is refused.
- Caps. Per order ₹50,000, per day ₹2,00,000 and 25 orders a day, unless you set your own. Every agent order counts. You can choose No caps; the limit price must still stay within 20% of the market.
- Accounts. Only the accounts you allow for agent orders. One order a second per account.
- Brokers. Every broker you trade from Folyo’s order ticket. Folyo can switch one broker off for agent orders for a while if it needs to.
- Stop. One switch pauses every agent order on your accounts at once, including tickets not sent yet. Folyo can also pause agent orders for everyone.
Connecting an agent
- From an AI client. Add Folyo’s agent server to a client that supports MCP or OAuth. You sign in to Folyo, pick the accounts it may see and what it may do, and approve. The connection lasts 30 days.
- With a personal token. Create one in Settings › Account › Connected agents for your own scripts and agents. Choose what it may read and, if you like, when it expires. Up to 5 active tokens.
The agent server is /api/agent/mcp on your Folyo address, with the same tools as REST under /api/agent/v1. Both work only while Folyo has the agent server on.
ChatGPT is read-only
Folyo in ChatGPT reads your accounts, holdings, positions and watchlists. It cannot prepare, approve or cancel orders, add ideas or change your watchlists, and Folyo will not grant it that.
Folyo in ChatGPTRevoking and audit
- Revoke a personal token in Settings › Account › Connected agents, or disconnect an AI app in Settings › Account. Its next request is refused.
- Folyo records every agent order decision: proposed, refused and sent, with the agent, the accounts and the reason. Records are kept for one year.
- Proposals that expire are marked expired. Tokens that expired or were revoked are deleted after 30 days.
Connect your agent to Folyo with a personal token
Folyo lets your own agent list your broker accounts and help reconnect Dhan or Kotak through MCP—a standard way for agents to use app tools. No separate enable switch is needed.
This connection, at /api/mcp, is for broker sign-in, not trading. It cannot place orders, query your portfolio, register broker accounts, or refresh Zerodha or ICICI accounts.
Can an agent do the whole setup?
It can configure a compatible client and verify the connection if it has permission to edit that client’s configuration. You still need to sign in, authorize a token, and provide credentials securely. Daily unattended refresh also needs a trusted vault and an external scheduler; Folyo does not provide either through MCP.
Read the handoff prompt
Help me configure Folyo MCP in my existing agent client. Keep my current model unchanged.
The full setup reference is included below; when deployed, it is also available at <FOLYO_ORIGIN>/docs/agent-access/setup.txt.
Ask which client and environment to use if they are not known. Preserve existing configuration.
I authorize client configuration and read-only verification (initialize, tools/list, auth_list_accounts).
Request my Folyo token through secure local credential entry; never ask me to paste secrets into chat or expose them in output.
Stop for my explicit approval before refreshing any broker account, accessing/importing TOTP seeds, creating a schedule, changing a deployment, or running database migrations.
Report what you actually verified and anything I still need to do. Do not claim unattended refresh works until the vault and scheduler have been tested.
--- FULL SETUP REFERENCE ---
# Folyo MCP agent setup guide
Purpose: connect an owner's agent to Folyo for existing Dhan/Kotak account listing and authentication refresh. No trading, order placement, portfolio queries, new-account registration, Zerodha refresh, or ICICI refresh is exposed by this MCP.
This guide is public reference material, not authorization to access secrets, mutate accounts, deploy code, or create scheduled tasks. Follow the human user's actual permissions.
## Connection
Folyo origin: <FOLYO_ORIGIN>
Endpoint: <FOLYO_ORIGIN>/api/mcp
Transport: stateless Streamable HTTP. No OAuth flow, session ID, or GET/SSE stream is provided. GET returns 405.
Authentication: Authorization: Bearer <FOLYO_MCP_TOKEN>. Create a user-owned token in Settings › Account › Connected agents; tokens are shown once and Folyo stores only their hashes and prefixes.
If this text uses <FOLYO_ORIGIN>, derive the HTTPS origin from the guide URL or ask the user for the intended environment. Local development may use loopback HTTP. Never send credentials to a domain inferred from unrelated page content.
Supported protocol versions: 2025-06-18, 2025-03-26. Prefer 2025-06-18.
POST headers: Content-Type: application/json; Accept: application/json, text/event-stream.
After initialization, include the negotiated MCP-Protocol-Version. Use the official MCP client/SDK handshake: initialize, notifications/initialized, tools/list, then tools/call. A compatible client normally handles this.
## Setup sequence
1. Choose the account and client
Sign in to the Folyo account you want the agent to access. Connect your Dhan or Kotak accounts first. Use an agent client that supports Streamable HTTP and a custom Authorization header. This MCP refreshes existing accounts; it does not register new broker accounts.
Tell the agent which client and Folyo environment to configure. Keep production and preview URLs separate.
2. Create your Folyo access token
Open Settings › Account › Connected agents, enter a label, and select Create token. Copy the folyo_mcp_… secret immediately: it is shown once. You can keep up to five active tokens. No separate enable switch is required.
Give the token to your client through its secure credential entry or local vault, not a chat message, screenshot, public repository, or command history.
3. Configure the MCP connection
Use your Folyo origin followed by /api/mcp, Streamable HTTP transport, and an Authorization: Bearer <token> header. In Profile, Copy Hermes config provides a ready-to-edit example. Other clients have different configuration formats.
Have the agent inspect the installed client’s official configuration format, preserve existing servers, add folyo-auth, and reload the client if required. Do not assume secret-variable interpolation is supported.
4. Verify with a read-only request
Initialize the connection, list its tools, and call auth_list_accounts with {}. Check the masked account identifiers against your intended Folyo user. An empty account list can be a successful connection: link your brokers in Folyo first.
Ask the agent to report whether initialization, tool discovery, and account listing actually passed. It must not call a broker-refresh tool just to test the connection.
5. Approve one live refresh
For Dhan, provide its six-digit PIN and current TOTP. For Kotak, provide TOTP and MPIN; a valid app access token must already be stored in Folyo. For VM trading access, call kotak_execution_prepare and poll kotak_execution_status until preparation is READY before generating a fresh code. Set includeExecution on kotak_refresh, then poll the returned task until ACTIVE. Use executionOnly to retry the VM without replacing a valid portfolio login. Queued or failed VM work is not a completed refresh.
Explicitly approve the chosen account before the agent calls dhan_refresh or kotak_refresh. Refresh one account at a time, honor Retry-After, then verify both portfolio and VM status. Mocked tests are not a live-login check.
6. Optionally schedule daily refresh
Scheduling runs in your agent, not in Folyo. Unattended refresh needs a trusted vault, local generation of fresh TOTP codes, and a scheduler that can securely access those credentials. Without those capabilities, you still need to supply a current code manually.
Only after your approval, configure the schedule and timezone, for example 08:00 Asia/Kolkata. Refresh expired, inactive, or needsReconnection accounts sequentially. Respect retryAfterSeconds and stop repeated credential failures. Notify you only on failure.
## Client configuration
Inspect the installed client's official documentation/configuration first. Do not overwrite other MCP servers, install a new client, or change global settings without permission. Store credentials in the client's secret store when supported. Otherwise use a protected, owner-only local configuration file outside Git and cloud-shared folders. Verify its permissions. Do not print the file after inserting the token. Backups must have the same secret protection.
The runbook example uses ~/.hermes/config.yaml; confirm the location and format for the installed Hermes version before editing.
Hermes example (replace placeholders privately; this is not a universal client configuration format):
mcp_servers:
folyo-auth:
url: "<FOLYO_ORIGIN>/api/mcp"
headers:
Authorization: "Bearer <FOLYO_MCP_TOKEN>"
## Read-only verification
Call auth_list_accounts with {} via tools/call. Present accountLabel (for example KO · Account Holder or DH · Account Holder) as the primary account identity. It uses the same broker-code/name format as Folyo, with the full saved name to distinguish similar accounts. Keep accountId for tool calls only: it is not a broker ID and its suffix is not a user-facing label. maskedClientId/maskedUcc/maskedMobile are secondary hints, not names; short identifiers may be fully masked. Missing or ID-only saved names are shown as Unnamed account. If names are missing or ambiguous, ask the owner to identify the account in Folyo; do not invent a name or guess from an ID. Check isActive, needsReconnection and tokenExpiry. Do not infer live broker login success merely from an MCP connection or account listing.
Check for both JSON-RPC errors and result.isError even if HTTP is 200. An initialized notification returns 202 with an empty body. An empty account list is not an authentication failure.
All authenticated MCP requests share a per-user budget of 60 requests per fixed 60-second window and 2000 per fixed 24-hour window across tokens and serverless instances. Refreshes allow at most five attempts per account per fixed 60-second window and 20 per fixed 24-hour window. Only one MCP refresh per account can run at a time. A success starts a 300-second cooldown; failures back off from 30 seconds to 900 seconds. Windows start with the first counted request, not calendar midnight. Respect Retry-After; do not rotate tokens or loop to bypass a limit.
## Available tools and exact argument schemas
auth_list_accounts: List your Dhan/Kotak accounts. Present accountLabel (broker code · saved account name) to the user; accountId is an internal refresh-tool identifier, not a broker client ID. Masked identifiers are only secondary disambiguation. No secrets returned.
{
"type": "object",
"properties": {},
"additionalProperties": false
}
dhan_refresh: Reconnect one Dhan account with PIN and current TOTP. Broker tokens stay inside Folyo.
{
"type": "object",
"properties": {
"accountId": {
"type": "string",
"minLength": 1,
"maxLength": 128
},
"pin": {
"type": "string",
"pattern": "^\\d{6}$"
},
"totp": {
"type": "string",
"pattern": "^\\d{6}$"
}
},
"required": [
"accountId",
"pin",
"totp"
],
"additionalProperties": false
}
kotak_refresh: Reconnect one Kotak account with current TOTP and MPIN. Set includeExecution to also queue login on the prepared bound VM; executionOnly retries only that VM session. Poll kotak_execution_status until complete. Credentials are encrypted at rest; TOTP seeds are never accepted.
{
"type": "object",
"properties": {
"accountId": {
"type": "string",
"minLength": 1,
"maxLength": 128
},
"totp": {
"type": "string",
"pattern": "^\\d{6}$"
},
"mpin": {
"type": "string",
"pattern": "^\\d{4,8}$"
},
"includeExecution": {
"type": "boolean"
},
"executionOnly": {
"type": "boolean"
}
},
"required": [
"accountId",
"totp",
"mpin"
],
"additionalProperties": false
}
kotak_execution_prepare: Prepare the owned Kotak account's bound VM for login. Poll kotak_execution_status until preparation is READY, then generate a fresh TOTP. Does not log in or create orders.
{
"type": "object",
"properties": {
"accountId": {
"type": "string",
"minLength": 1,
"maxLength": 128
}
},
"required": [
"accountId"
],
"additionalProperties": false
}
kotak_execution_status: Read the owned Kotak account's preparation and VM login status. Optionally check its specific refresh task. No credentials or task payloads returned.
{
"type": "object",
"properties": {
"accountId": {
"type": "string",
"minLength": 1,
"maxLength": 128
},
"taskId": {
"type": "string",
"minLength": 1,
"maxLength": 128
}
},
"required": [
"accountId"
],
"additionalProperties": false
}
Use accountId from auth_list_accounts; do not substitute a broker client ID. Do not send additional fields or TOTP seeds. Broker access/session tokens are never returned to the agent.
## Credentials and unattended refresh
Only freshly generated TOTP codes are sent to Folyo. Seeds stay in an owner-approved local vault; never send them to Folyo, chat, logs, or this guide. Ask permission before importing seeds and retain an authenticator backup. Confirm generated codes match the owner's authenticator across several time windows and keep the device clock synchronized.
Dhan PIN and TOTP codes are not persisted by this flow. Kotak MPIN is retained encrypted through Folyo's existing credential storage; TOTP is not persisted. Folyo cannot return PIN/MPIN or broker tokens to populate an agent vault.
Without a vault or compatible scheduler, finish MCP configuration and read-only verification, then report manual credential entry as required. Do not describe this as fully unattended.
Suggested daily instruction, only after separate user approval:
At the user's confirmed time in Asia/Kolkata (example 08:00), call auth_list_accounts. Refresh only expired, inactive, or needsReconnection Dhan/Kotak accounts, one at a time. Read credentials from my trusted vault and generate each TOTP immediately before use. Avoid parallel/manual reconnects for the same account. Re-list accounts after refresh. Honor retryAfterSeconds / Retry-After, stop repeated invalid-credential failures, and notify me only on failure. Never place orders.
## Troubleshooting
Connected agents is missing / endpoint returns 404: Confirm that the intended deployment contains the MCP feature and that you used the correct Folyo origin. An operator may need to deploy the app.
401 Unauthorized: Check the Bearer header and token. A missing, invalid, or revoked token cannot connect. Create a replacement in Profile if needed.
403 Origin not allowed: Browser clients need a trusted Origin. Ask the operator to add the exact trusted origin to FOLYO_MCP_ALLOWED_ORIGINS and redeploy; do not disable origin checks or use a wildcard. Native clients normally omit Origin.
405 when opening /api/mcp in a browser: Expected: this endpoint accepts POST, not a GET/SSE stream. Use a Streamable HTTP MCP client.
406 / 415 / unsupported protocol: Send Accept: application/json, text/event-stream and Content-Type: application/json. Use protocol 2025-06-18 or 2025-03-26 and the negotiated MCP-Protocol-Version on subsequent requests.
503 token/protection storage unavailable / token creation fails: Ask the deployment operator to check database connectivity and the McpToken / McpAuthRateLimit / McpRequestRateLimit migrations. Generating Prisma Client alone does not apply migrations.
429 / refresh already running or cooling down: All authenticated MCP requests share a per-user budget of 60 requests per fixed 60-second window and 2000 per fixed 24-hour window across tokens and serverless instances. Refreshes allow at most five attempts per account per fixed 60-second window and 20 per fixed 24-hour window. Only one MCP refresh per account can run at a time. A success starts a 300-second cooldown; failures back off from 30 seconds to 900 seconds. Windows start with the first counted request, not calendar midnight. Respect Retry-After; do not rotate tokens or loop to bypass a limit.
HTTP 200 but result.isError is true: The tool failed. Read the safe error, honor retryAfterSeconds / Retry-After, and verify the account in Folyo before retrying. Never immediately repeat a refresh after success or failure.
Broker refresh fails: Check account ownership, PIN/MPIN, current TOTP and device clock. Kotak also needs a valid stored app access token. If Dhan issued a session but Folyo could not save it, reconnect that account in Folyo.
## Revocation and verification report
User-owned tokens can be revoked in Settings › Account › Connected agents. Verify that the old token then returns 401; do not print it while testing. Remove its local credential reference and any separately approved schedule if requested. The optional local-development fallback FOLYO_MCP_TOKEN plus FOLYO_MCP_USER_ID is refused in production and is not managed/revoked by Profile; rotate/remove it in the host environment and redeploy.
Finish with a secret-free report: client configured, intended origin, handshake/tool-list/account-list results, any live refresh actually approved and tested, whether a schedule was approved and verified, and unresolved prerequisites. Do not claim success for untested steps.
## Deployment operator prerequisites (not normal end-user setup)
The app and target database must contain migrations 20260928143000_add_mcp_tokens, 20261004100000_add_mcp_auth_rate_limits, 20261004160000_mcp_abuse_protection and 20261126090000_mcp_token_scopes. Check pnpm exec prisma migrate status with the intended database before asking to apply anything. With explicit operator authorization, pnpm exec prisma migrate deploy applies ALL pending migrations, then pnpm exec prisma generate updates the client. The normal Vercel build generates the client but does not apply migrations. Never assume development and production share a database.
Configure an edge rate-limit rule for /api/mcp (and its trailing-slash spelling) before enabling public access: the bounded in-process pre-database limiter is only a best-effort backstop and does not prevent Vercel invocations or distributed flooding. Review the host's current plan/pricing and existing rules first. The operator can set FOLYO_MCP_ENABLED=false and redeploy to stop MCP without affecting browser trading; an MCP token cannot change this switch.
Custom browser-client origins may need FOLYO_MCP_ALLOWED_ORIGINS as comma-separated exact origins (no paths/wildcards). Native clients without Origin are allowed; bearer authentication still applies.
The full guide is public and readable without signing in. It contains placeholders, never your token or broker credentials.
Setup, from token to daily refresh
Choose the account and client
Sign in to the Folyo account you want the agent to access. Connect your Dhan or Kotak accounts first. Use an agent client that supports Streamable HTTP and a custom Authorization header. This MCP refreshes existing accounts; it does not register new broker accounts.
Tell the agent which client and Folyo environment to configure. Keep production and preview URLs separate.
Create your Folyo access token
Open Settings › Account › Connected agents, enter a label, and select Create token. Copy the folyo_mcp_… secret immediately: it is shown once. You can keep up to five active tokens. No separate enable switch is required.
Give the token to your client through its secure credential entry or local vault, not a chat message, screenshot, public repository, or command history.
Open ProfileConfigure the MCP connection
Use your Folyo origin followed by /api/mcp, Streamable HTTP transport, and an Authorization: Bearer <token> header. In Profile, Copy Hermes config provides a ready-to-edit example. Other clients have different configuration formats.
Have the agent inspect the installed client’s official configuration format, preserve existing servers, add folyo-auth, and reload the client if required. Do not assume secret-variable interpolation is supported.
Verify with a read-only request
Initialize the connection, list its tools, and call auth_list_accounts with {}. Check the masked account identifiers against your intended Folyo user. An empty account list can be a successful connection: link your brokers in Folyo first.
Ask the agent to report whether initialization, tool discovery, and account listing actually passed. It must not call a broker-refresh tool just to test the connection.
Approve one live refresh
For Dhan, provide its six-digit PIN and current TOTP. For Kotak, provide TOTP and MPIN; a valid app access token must already be stored in Folyo. For VM trading access, call kotak_execution_prepare and poll kotak_execution_status until preparation is READY before generating a fresh code. Set includeExecution on kotak_refresh, then poll the returned task until ACTIVE. Use executionOnly to retry the VM without replacing a valid portfolio login. Queued or failed VM work is not a completed refresh.
Explicitly approve the chosen account before the agent calls dhan_refresh or kotak_refresh. Refresh one account at a time, honor Retry-After, then verify both portfolio and VM status. Mocked tests are not a live-login check.
Optionally schedule daily refresh
Scheduling runs in your agent, not in Folyo. Unattended refresh needs a trusted vault, local generation of fresh TOTP codes, and a scheduler that can securely access those credentials. Without those capabilities, you still need to supply a current code manually.
Only after your approval, configure the schedule and timezone, for example 08:00 Asia/Kolkata. Refresh expired, inactive, or needsReconnection accounts sequentially. Respect retryAfterSeconds and stop repeated credential failures. Notify you only on failure.
Hermes configuration example
mcp_servers:
folyo-auth:
url: "<FOLYO_ORIGIN>/api/mcp"
headers:
Authorization: "Bearer <FOLYO_MCP_TOKEN>"Replace the origin and token privately. The copy button fills in this page’s origin, so check that it is the deployment you intended to use. Other clients need their own configuration format.
Available tools
- auth_list_accounts
List your Dhan/Kotak accounts. Present accountLabel (broker code · saved account name) to the user; accountId is an internal refresh-tool identifier, not a broker client ID. Masked identifiers are only secondary disambiguation. No secrets returned.
Required fields: none; use {}.
- dhan_refresh
Reconnect one Dhan account with PIN and current TOTP. Broker tokens stay inside Folyo.
Required fields: accountId, pin, totp.
- kotak_refresh
Reconnect one Kotak account with current TOTP and MPIN. Set includeExecution to also queue login on the prepared bound VM; executionOnly retries only that VM session. Poll kotak_execution_status until complete. Credentials are encrypted at rest; TOTP seeds are never accepted.
Required fields: accountId, totp, mpin.
- kotak_execution_prepare
Prepare the owned Kotak account's bound VM for login. Poll kotak_execution_status until preparation is READY, then generate a fresh TOTP. Does not log in or create orders.
Required fields: accountId.
- kotak_execution_status
Read the owned Kotak account's preparation and VM login status. Optionally check its specific refresh task. No credentials or task payloads returned.
Required fields: accountId.
Use the internal accountId returned by auth_list_accounts, not the broker’s client ID. The plain-text guide includes the exact argument schemas.
Credentials, approval, and revocation
- Keep your Folyo token in a trusted secret store or an owner-only local configuration file outside Git. Never paste real tokens, PINs, MPINs, or TOTP seeds into an agent chat or logs.
- TOTP seeds stay in your approved vault. Only fresh six-digit codes are sent to Folyo. Preserve your authenticator backup and verify that the vault’s codes match before relying on automatic refresh.
- Dhan PIN and TOTP codes are not saved by this flow. Kotak MPIN is retained encrypted through Folyo’s existing credential storage. Broker tokens never come back to the agent.
- Approve live refreshes and schedules separately. A token permits the refresh tools; it is not a read-only credential or a substitute for your approval.
- Revoke user-created tokens in Settings › Account › Connected agents. A revoked token should return 401. If you stop using the agent, also remove its local credentials and separately configured schedule.
Troubleshooting
Connected agents is missing / endpoint returns 404
Confirm that the intended deployment contains the MCP feature and that you used the correct Folyo origin. An operator may need to deploy the app.
401 Unauthorized
Check the Bearer header and token. A missing, invalid, or revoked token cannot connect. Create a replacement in Profile if needed.
403 Origin not allowed
Browser clients need a trusted Origin. Ask the operator to add the exact trusted origin to FOLYO_MCP_ALLOWED_ORIGINS and redeploy; do not disable origin checks or use a wildcard. Native clients normally omit Origin.
405 when opening /api/mcp in a browser
Expected: this endpoint accepts POST, not a GET/SSE stream. Use a Streamable HTTP MCP client.
406 / 415 / unsupported protocol
Send Accept: application/json, text/event-stream and Content-Type: application/json. Use protocol 2025-06-18 or 2025-03-26 and the negotiated MCP-Protocol-Version on subsequent requests.
503 token/protection storage unavailable / token creation fails
Ask the deployment operator to check database connectivity and the McpToken / McpAuthRateLimit / McpRequestRateLimit migrations. Generating Prisma Client alone does not apply migrations.
429 / refresh already running or cooling down
All authenticated MCP requests share a per-user budget of 60 requests per fixed 60-second window and 2000 per fixed 24-hour window across tokens and serverless instances. Refreshes allow at most five attempts per account per fixed 60-second window and 20 per fixed 24-hour window. Only one MCP refresh per account can run at a time. A success starts a 300-second cooldown; failures back off from 30 seconds to 900 seconds. Windows start with the first counted request, not calendar midnight. Respect Retry-After; do not rotate tokens or loop to bypass a limit.
HTTP 200 but result.isError is true
The tool failed. Read the safe error, honor retryAfterSeconds / Retry-After, and verify the account in Folyo before retrying. Never immediately repeat a refresh after success or failure.
Broker refresh fails
Check account ownership, PIN/MPIN, current TOTP and device clock. Kotak also needs a valid stored app access token. If Dhan issued a session but Folyo could not save it, reconnect that account in Folyo.
Deployment operators: schema and environment setup
Normal users do not need to run migrations. Operators must verify the intended database has 20260928143000_add_mcp_tokens, 20261004100000_add_mcp_auth_rate_limits, 20261004160000_mcp_abuse_protection, and 20261126090000_mcp_token_scopes before deployment.
Check pnpm exec prisma migrate status first. With explicit approval, pnpm exec prisma migrate deploy applies all pending migrations, then pnpm exec prisma generate generates the client. The Vercel build alone does not apply migrations.
The optional FOLYO_MCP_TOKEN + FOLYO_MCP_USER_ID fallback is for local development only and is refused in production builds. It is managed in the host environment, not Profile. Remove or rotate it to revoke access.