Skip to main content

Connect OpenCode

Connect OpenCode to SolarSENS MCP and ask read-only questions about the Plants available to your SolarSENS account.

Before you start

  • Install OpenCode 2 or a later version.
  • Use a project folder where OpenCode can create opencode.json.
  • Ask your SolarSENS administrator for an OpenCode OAuth client ID if the connection reports needs auth.

The MCP login is separate from the SolarSENS web application login. Do not put your SolarSENS password or an access token in opencode.json.

Use the canonical server

For SolarSENS data, use only:

https://mcp.solarsens.co/mcp

Do not use a date-stamped workers.dev URL, a server named solarsens-preview, or a fixture token. Those were test deployments and are not connected to the signed-in SolarSENS account or its Plant scope. If an old server appears in an OpenCode session, start a new session and keep only the solarsens entry in opencode.json.

Add the server

From your project folder, run:

opencode mcp add solarsens --url https://mcp.solarsens.co/mcp

This creates a project configuration similar to the anonymized illustration below. It contains no account, Plant, or token data.

An anonymized OpenCode project configuration illustration showing the SolarSENS MCP URL

{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"solarsens": {
"type": "remote",
"url": "https://mcp.solarsens.co/mcp"
}
}
}
}

Check the connection entry:

opencode mcp list

Before sign-in, OpenCode may show:

solarsens  needs authentication

This means OpenCode found the server. It has not received an OAuth token yet.

Complete OAuth sign-in

SolarSENS currently uses a pre-registered Auth0 Native application for local OpenCode callbacks. If automatic registration is not available, add the OAuth settings below to the solarsens entry. Replace the client ID with the value provided by your administrator.

{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"solarsens": {
"type": "remote",
"url": "https://mcp.solarsens.co/mcp",
"oauth": {
"client_id": "{env:SOLARSENS_MCP_CLIENT_ID}",
"scope": "openid profile email read:data",
"callback_port": 6080,
"redirect_uri": "http://localhost:6080/auth/callback"
}
}
}
}
}

Keep the client ID in your local environment when possible:

export SOLARSENS_MCP_CLIENT_ID="your-pre-registered-client-id"
opencode mcp auth solarsens

OpenCode opens the SolarSENS authorization page. Sign in, review the read-only access request, and approve it. OpenCode stores the OAuth token in its local credential store; it does not write the token to the project file.

The approval screen should show the SolarSENS MCP application and the read-only profile request. The account name in this illustration is generic.

An anonymized SolarSENS OAuth approval screen for OpenCode

You can also start the flow from the OpenCode interface. Type / in the chat box and choose the command that opens MCPs. In OpenCode 2.0.7, the command is /mcp.

An anonymized OpenCode MCP panel illustration showing the SolarSENS server before OAuth sign-in

After approval, run opencode mcp list again. The server must no longer show needs authentication or failed before you ask for Plant data. The expected state is:

solarsens  connected

Say hello, then test access

Start with a simple chat message:

Hello SolarSENS

Then test the MCP connection and account scope with one message:

Say hello SolarSENS. Then list only the SolarSENS Plants this signed-in
account is authorised to view. Return each Plant name and ID. Do not query any
Plant outside that scope.

The greeting confirms that OpenCode can chat in the project. The Plant question confirms the MCP connection, OAuth session, and SolarSENS access scope. Do not use a Plant name that you are not authorised to view. If you need to find a named Plant, provide its name or code; do not ask the agent to probe one-letter or one-digit search terms.

This anonymized clean-session illustration shows the expected project and canonical MCP URL. It contains no account, Plant, or token data.

An anonymized clean OpenCode session showing the canonical SolarSENS MCP URL

The successful response should show only Plants in the signed-in account scope. A demo account normally shows one demo Plant, as in this redacted example:

An anonymized OpenCode response showing one authorized SolarSENS demo Plant

Troubleshooting

What you seeWhat to do
needs authenticationComplete opencode mcp auth solarsens, or use the pre-registered OAuth block above.
failed or 401 after sign-inRun opencode mcp logout solarsens, authenticate again, and wait for connected before asking for Plant data.
dynamic client registration is disabledAsk your administrator for the pre-registered client ID and use the loopback callback configuration above.
OAuth succeeds but no Plants appearAsk your administrator to check the Auth0-to-SolarSENS account mapping and Plant scope.
A Plant is forbiddenThe Plant is outside the signed-in account scope. Do not try another Plant ID.
An old workers.dev or solarsens-preview server appearsRemove that project entry, start a new session, and configure only https://mcp.solarsens.co/mcp.
The MCP panel is emptyOpen the project folder that contains opencode.json, then reload OpenCode.

The SolarSENS MCP is read-only. It does not acknowledge alarms, create work orders, or change Plant configuration.

For OpenCode's current OAuth options, see the OpenCode MCP server guide.