Create Private Connection from OpenCode

This page explains how to register OpenCode as an OAuth client in Pricefx and configure an authenticated MCP connection in OpenCode.

Prerequisites

OAuth Client ID Registration

To use OAuth, each client must be registered with a specific client_id. This configuration is defined through the oauthConfiguration Advanced Configuration Option. Multiple clients can be registered within this setting.

  1. Login to your Pricefx partition.

  2. Go to Administration > Configuration > System Configuration > Advanced Configuration Options.

  3. Click Add.

  4. In the Add Option menu:

    1. Enter oauthConfiguration into Name.

    2. Enter the following JSON code into Value.

      1. Replace the <client_id> with a name of your choosing, usually open-code.

      2. Replace the <port_number> with a port of your choosing, usually 3334.

        JSON
        {
          "knownClients": {
            "<client_id>": {
              "redirect_uri": "http://127.0.0.1:<port_number>/mcp/oauth/callback"
            }
          }
        }
        
  5. Click Add.

Property

Example Value

Required

Description

client_id

opencode

Yes

Client ID example.

redirect_uri

http://127.0.0.1:<port_number>/mcp/oauth/callback

Yes

Must be configured, as it will be sent by the client. See below about <port_number>

port_number (configurable)

19876

Yes

The port on your local machine which OpenCode will use for OAuth handshake. This can be any valid port of your choosing, OpenCode documentations most often use port 19876 as shown in examples.

MCP Connection

  1. Open your terminal.

  2. Type the following command to start a helper process which will guide you through install

    Bash
    opencode mcp add
    

    info Review the following table before selecting wizard options.

  3. If you would like to configure a custom callback port, see the JSON example below to customize. (Optional)

  4. Type the following command into your terminal to authenticate.

    Bash
    opencode mcp auth <server_name>
    

Variable

Description

Location

The Current Project or Global, depending on whether you would like this MCP connection applied only in this project or everywhere every time.

MCP Server Name

This option can be any general label you like, such as my-dev-partition.

MCP Server Type

remote

MCP Server URL

The https://mcp.pricefx.com/mcp/<cluster_host>/<partition> URL. Make sure to replace the <variables> with your target partition details.

Require OAuth

Yes

MCP Client ID

The <client_id> as you configured in the Advanced Configuration JSON above.

MCP Client Secret

No

MCP JSON

If you would like to directly add the MCP server via JSON configuration instead of the terminal command above, you can use the below example reference. Make sure to replace the same <variables> as above.

info Note, the callbackPort field can be omitted entirely if you do not wish to customize.

JSON
"<server_name>": {
  "type": "remote",
  "url": "https://mcp.pricefx.com/mcp/<cluster_host>/<partition>",
  "oauth": {
    "clientId": "<client_id>",
    "callbackPort": <port_number>
  }
}

Variable

Description

<client_id>

Replace the <client_id> with the value you chose, for example open-code.

<port_number>

Replace the  <port_number> with the value you chose, for example 3334.

<server_name>

Replace <server_name> with any name you like, this is the local label used to refer to this connection, typically like pricefx-my-dev-partition or similar, named after your partition.

<partition>

Replace <partition> with your partition name, for example my-dev-partition.

<cluster_host>

Replace the <cluster_host> with appropriate value, for example demofx-staging.pricefx.com.