Connect a client
The guided command supports Cursor, Claude, ChatGPT and VS Code. It writes only the client configuration required for MCP. Windsurf uses the same remote server, with its own JSON field names; there is no connect windsurf target.
$ npx mybarn connect cursor
$ npx mybarn connect claude
$ npx mybarn connect vscode
$ npx mybarn connect chatgpt
Add --stdio on Cursor, Claude Desktop or VS Code when you need the local proxy. ChatGPT is remote-only; --stdio is ignored.
The URL the CLI writes comes from MYBARN_API, the saved CLI apiUrl, or http://localhost:3101. Public production is https://api.mybarn.sh/mcp. Snippets below use the production origin; replace it if you are on localhost.
Connect also installs the mybarn.sh protocol files in the current repo (AGENTS.md and the client rule files). That is separate from the MCP JSON.
Remote vs stdio
Remote (default) — Streamable HTTP. The client opens OAuth 2.1 (dynamic registration) against {API_ORIGIN}/mcp. You do not need mybarn login for the MCP session. The barn is chosen on the consent screen. remember must pass context: a git repository (github.com/org/repo, branch, commit) or a non-git editor project (cursor/folder-name). The first write links that project to the token barn.
stdio (fallback) — the client starts npx -y mybarn mcp. The proxy injects the same project identity when the agent omits it. That path still needs mybarn login.
$ npx mybarn connect cursor --stdio
Cloud (Streamable HTTP)
Use this payload in any client that asks for a remote MCP URL, including Claude.ai connectors and ChatGPT connectors.
{
"url": "https://api.mybarn.sh/mcp"
}
Auth is OAuth 2.1 with dynamic client registration. There is no API key in the JSON. Paste the URL, then finish Connect / OAuth in the client.
Local equivalent:
{
"url": "http://localhost:3101/mcp"
}
Cursor
When: remote for a hosted barn with OAuth in Cursor; --stdio when you want the local proxy to attach project identity automatically.
CLI: npx mybarn connect cursor or npx mybarn connect cursor --stdio
File: .cursor/mcp.json in the current working directory (the project root when you run the command).
Remote (what the CLI writes):
{
"mcpServers": {
"mybarn": {
"url": "https://api.mybarn.sh/mcp"
}
}
}
stdio (what --stdio writes):
{
"mcpServers": {
"mybarn": {
"command": "npx",
"args": ["-y", "mybarn", "mcp"]
}
}
}
The CLI merges mybarn into any existing mcpServers object. After a remote write, paste the URL or open Connect in Cursor to finish OAuth.
Claude Desktop
When: Claude for desktop can run remote OAuth or a local stdio process. Prefer remote unless you want the local proxy.
CLI: npx mybarn connect claude or npx mybarn connect claude --stdio
File (user-wide, not the repo):
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
Remote:
{
"mcpServers": {
"mybarn": {
"url": "https://api.mybarn.sh/mcp"
}
}
}
stdio:
{
"mcpServers": {
"mybarn": {
"command": "npx",
"args": ["-y", "mybarn", "mcp"]
}
}
}
Restart Claude Desktop after the file changes. The wrapper key is mcpServers, same as Cursor, in Claude’s desktop config rather than a project file.
Claude.ai (cloud)
When: Claude in the browser. Cloud connectors are remote only — there is no stdio process on claude.ai.
CLI: npx mybarn connect claude still writes the desktop file above. For Claude.ai, take the URL the command prints and add a custom connector. Do not paste the desktop mcpServers wrapper into the cloud UI.
Connector payload:
{
"url": "https://api.mybarn.sh/mcp"
}
Auth: OAuth 2.1 (dynamic registration). Finish the consent screen and pick one barn.
ChatGPT
When: ChatGPT connectors / custom GPT remote MCP. ChatGPT is remote only. npx mybarn connect chatgpt --stdio does not write a stdio server.
CLI: npx mybarn connect chatgpt
File: none. The CLI prints the URL, the auth scheme, and the mybarn.sh protocol to paste into Custom Instructions.
Connector payload:
{
"url": "https://api.mybarn.sh/mcp"
}
Auth: OAuth 2.1 (dynamic registration).
VS Code
When: Copilot / MCP in VS Code. Remote for OAuth in the editor; --stdio for the local proxy.
CLI: npx mybarn connect vscode or npx mybarn connect vscode --stdio
File: .vscode/mcp.json in the current working directory.
VS Code is the only guided target that uses a servers root key instead of mcpServers.
Remote:
{
"servers": {
"mybarn": {
"url": "https://api.mybarn.sh/mcp"
}
}
}
stdio:
{
"servers": {
"mybarn": {
"command": "npx",
"args": ["-y", "mybarn", "mcp"]
}
}
}
The CLI merges mybarn into an existing servers or mcpServers object, then writes { "servers": … }.
Windsurf
When: Cascade MCP. The product talks to the same {API_ORIGIN}/mcp endpoint. The CLI has no windsurf target — copy the JSON below yourself.
CLI: none. Use npx mybarn connect cursor if you also want protocol files in the repo, then add Windsurf’s file by hand.
File: Windsurf → Cascade → MCP → View Raw Config (mcp_config.json). Typical paths are ~/.codeium/windsurf/mcp_config.json or ~/.codeium/mcp_config.json.
Remote Windsurf uses serverUrl, not url. A Cursor block pasted unchanged will not connect.
{
"mcpServers": {
"mybarn": {
"serverUrl": "https://api.mybarn.sh/mcp"
}
}
}
stdio (same command / args as Cursor):
{
"mcpServers": {
"mybarn": {
"command": "npx",
"args": ["-y", "mybarn", "mcp"]
}
}
}
Refresh the MCP list in Cascade after saving. stdio still needs mybarn login. Project identity is attached on remember either by the agent or by the local proxy.