Help Center / MCP Server / OpenCode

Connect KasLens to OpenCode

Access Kaspa data from your terminal AI agent.

Connect KasLens to OpenCode

OpenCode is an interactive CLI coding agent that runs in your terminal. This guide shows you how to connect the KasLens MCP server to OpenCode so it can access real-time Kaspa market data and analytics.

Prerequisites

Reminder: Check your spam/junk folder if you did not receive the verification email from [email protected].


Step 1: Add the MCP Server to Your Configuration

OpenCode uses a JSON configuration file to manage MCP servers. Open your OpenCode config file:

  • Global config: ~/.config/opencode/opencode.jsonc
  • Project config: opencode.jsonc in your project root

Add the KasLens MCP server to the mcpServers section:

{
  "mcpServers": {
    "kaslens": {
      "enabled": true,
      "type": "remote",
      "url": "https://kaspa-lens.com/mcp",
      "oauth": {}
    }
  }
}

Step 2: Start OpenCode and Authenticate

  1. Start OpenCode in your terminal:
opencode
  1. OpenCode will detect the new MCP server and initiate the OAuth flow
  2. A browser window will open showing the KasLens login page — if the browser does not open automatically, go to your terminal and run:
opencode mcp auth kaslens
  1. Log in with your KasLens email and password
  2. Authorize OpenCode to access your KasLens data
  3. Return to your terminal — OpenCode will confirm the connection

Step 3: Start Using It

You can now ask OpenCode about Kaspa data. For example:

  • "What is the current Kaspa price and 24h volume?"
  • "What are the economic events today and how might they influence the Kaspa price?"
  • "Summarize today's Kaspa daily pulse"
  • "Show me the top 10 Kaspa addresses by balance"
  • "What KRC-20 tokens have the highest market cap?"

OpenCode will call the KasLens MCP server to fetch live data and provide answers directly in your terminal.


Re-authenticating

OpenCode stores OAuth tokens locally. If your session expires, OpenCode will automatically open the browser for you to re-authenticate. You can also manually trigger re-authentication:

opencode mcp auth kaslens

Troubleshooting

"Connection refused" or timeout

Make sure you have internet access and that https://kaspa-lens.com/mcp is reachable. You can test with:

curl -s -o /dev/null -w "%{http_code}" https://kaspa-lens.com/mcp

You should get a 405 response (Method Not Allowed — the MCP endpoint expects POST, not GET). This confirms the server is reachable.

Browser does not open for authentication

If your terminal environment does not support opening browsers, OpenCode will print a URL for you to open manually. Copy and paste it into your browser.

"Email not verified"

You need to verify your email address before you can log in. Check your inbox (and spam folder) for the verification email from [email protected].

Debugging connection issues

If something is not working, OpenCode provides built-in diagnostics for MCP servers. Run the following command to test the connection, check OAuth status, and verify the discovery flow:

opencode mcp debug kaslens

To check the auth status of all configured MCP servers:

opencode mcp auth list

For more detailed information, check the OpenCode log files at ~/.local/share/opencode/log/. You can also start OpenCode with verbose logging to get more debug output:

opencode --log-level DEBUG

See the OpenCode Troubleshooting guide and the MCP servers documentation for more details.