opal-mcp

opal-mcp

MCP server for interacting with the Opal Security platform, enabling operations like managing access rules, apps, and bundles via natural language.

Category
访问服务器

README

opal-mcp

Developer-friendly & type-safe Typescript SDK specifically catered to leverage opal-mcp API.

<div align="left"> <a href="https://www.speakeasy.com/?utm_source=opal-mcp&utm_campaign=typescript"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a> <a href="https://opensource.org/licenses/MIT"> <img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" /> </a> </div>

<!-- Start Summary [summary] -->

Summary

Opal API: The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically. <!-- End Summary [summary] -->

<!-- Start Table of Contents [toc] -->

Table of Contents

<!-- $toc-max-depth=2 -->

<!-- End Table of Contents [toc] -->

<!-- Start Running MCP [run-mcp] -->

Model Context Protocol (MCP) Server

This SDK is also an installable MCP server where the various SDK methods are exposed as tools that can be invoked by AI applications.

⚠️ WARNING: Node.js v20 or greater is required to run the MCP server from npm.

Generating an API Key

To authenticate with the Opal API, you'll need to generate an API token:

  1. Log in to the Opal dashboard as an Admin
  2. Navigate to the Settings page
  3. Select the API Tokens section
  4. Click "Generate new token"
  5. Choose the appropriate access level:
    • Read-only: For applications that only need to view resources
    • Full-access: For applications that need to create or modify resources
  6. Set an expiration date (optional but recommended for security)
  7. Add a descriptive label to identify the token's purpose
  8. Save the token securely - it will only be displayed once

If a token is compromised, you can revoke it at any time from the Opal Admin page.

For more information, see the Opal API Authentication Documentation.

Environment Variables

The following environment variables can be used to configure the SDK and MCP server:

Variable Name Description Default
API_TOKEN The API token for MCP server authentication Required for MCP server
PORT The port number for the MCP server 32000
SERVER_URL The base URL for the Opal API https://api.opal.dev/v1
LOG_LEVEL Logging level for the MCP server info

Installation

The library can be installed with either npm, pnpm, bun or yarn package managers.

NPM

npm add opal-mcp

PNPM

pnpm add opal-mcp

Bun

bun add opal-mcp

Yarn

yarn add opal-mcp zod

# Note that Yarn does not install peer dependencies automatically. You will need
# to install zod as shown above.

[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.

<details> <summary>Claude installation steps</summary>

Add the following server definition to your claude_desktop_config.json file:

{
  "mcpServers": {
    "OpalMcp": {
      "command": "npx",
      "args": [
        "-y", "--package", "opal-mcp",
        "--",
        "mcp", "start",
        "--bearer-auth", "<API_TOKEN>"
      ]
    }
  }
}

</details>

<details> <summary>Cursor installation steps</summary>

Create a .cursor/mcp.json file in your project root with the following content:

{
  "mcpServers": {
    "OpalMcp": {
      "command": "npx",
      "args": [
        "-y", "--package", "opal-mcp",
        "--",
        "mcp", "start",
        "--bearer-auth", "<API_TOKEN>"
      ]
    }
  }
}

</details>

You can also run MCP servers as a standalone binary with no additional dependencies. You must pull these binaries from available Github releases:

curl -L -o mcp-server \
    https://github.com/opalsecurity/opal-mcp/releases/download/v0.0.6/mcp-server-bun-darwin-arm64 && \
chmod +x mcp-server

If the repo is a private repo you must add your Github PAT to download a release -H "Authorization: Bearer {GITHUB_PAT}".

{
  "mcpServers": {
    "Todos": {
      "command": "./DOWNLOAD/PATH/mcp-server",
      "args": [
        "start"
      ]
    }
  }
}

For a full list of server arguments, run:

npx -y --package opal-mcp -- mcp start --help

Running the MCP Server with Docker

The SDK includes a Dockerfile and docker-compose.yaml for easy containerization and deployment.

Using docker-compose

  1. Create a .env file with your configuration:

    BEARER_AUTH=your_api_key_here
    PORT=32000
    SERVER_URL=https://api.opal.dev/v1
    LOG_LEVEL=info
    
  2. Run the server using docker-compose:

    docker-compose up -d
    
  3. Configure your MCP client to connect to the server by adding the following to your configuration file:

    {
      "mcpServers": {
        "opal-mcp": {
          "url": "http://localhost:32000/sse",
          "env": {
            "API_KEY": "your_api_key_here"
          }
        }
      }
    }
    

Building and running manually

You can also build and run the Docker image directly:

# Build the image
docker build -t opal-mcp-server .

# Run the container
docker run -p 32000:32000 -e BEARER_AUTH=your_api_key_here opal-mcp-server

Troubleshooting MCP

Here are some common issues you might encounter when using the MCP server and how to resolve them:

Connection Issues

  • Server Not Starting

    • Verify Node.js version is v20 or greater
    • Check if port 32000 is already in use
    • Ensure you have proper permissions to run the server
    • Try running with LOG_LEVEL=debug for more detailed output
  • Authentication Failures

    • Verify your API token is valid and not expired
    • Check if the token has the correct permissions
    • Ensure the token is properly set in the environment variables
    • Confirm the SERVER_URL points to the correct environment

Performance Issues

  • Slow Response Times
    • Check network connectivity to the Opal API
    • Be aware of the token limit for the model you are using and the number of paginated results
    • Unlikely. Verify you're not hitting rate limits Opal API Rate Limits

Integration Issues

  • Cursor/Claude Not Connecting
    • Verify your mcp.json configuration is correct
    • Ensure the MCP server is running before starting Cursor/Claude
    • Check if the bearer auth token is properly formatted
    • Confirm the SSE endpoint URL is accessible
    • Ensure only one Cursor/Claude window is open

Common Error Messages

  • Error: listen EADDRINUSE: address already in use :::32000

    • Another process is using port 32000
    • Either stop the other process or change the PORT environment variable
  • Error: Invalid bearer auth token

    • The provided API token is invalid or malformed
    • Generate a new token from the Opal dashboard
  • Error: Node.js version must be >= 20.0.0

    • Update your Node.js installation to version 20 or greater

For additional help, you can:

  • Set LOG_LEVEL=debug for more detailed logs
  • Check the Opal API Documentation
  • File an issue on the GitHub repository <!-- End Running MCP [run-mcp] -->

<!-- No SDK Installation [installation] -->

<!-- No Requirements [requirements] -->

<!-- No SDK Example Usage [usage] -->

<!-- No Authentication [security] -->

<!-- Start Available Resources and Operations [operations] -->

Available Resources and Operations

<details open> <summary>Available methods</summary>

accessRules

  • createAccessRule - Creates a new access rule config for the given group_id.
  • getAccessRule - Returns a list of access rule config given the group_id of the access rule.
  • updateAccessRule - Updates the access rule config for the given group_id.

apps

  • getApps - Returns a list of App objects.
  • getApp - Returns an App object.
  • getSyncErrors - Returns a list of recent sync errors that have occurred since the last successful sync.

bundles

configurationTemplates

events

  • events - Returns a list of Event objects.

groupBindings

groups

idpGroupMappings

messageChannels

nonHumanIdentities

  • getNhis - Returns a list of non-human identities for your organization.

onCallSchedules

owners

  • getOwners - Returns a list of Owner objects.
  • createOwner - Creates an owner.
  • updateOwners - Bulk updates a list of owners.
  • getOwner - Returns an Owner object.
  • deleteOwner - Deletes an owner.
  • getOwnerFromName - Returns an Owner object. Does not support owners with / in their name, use /owners?name=... instead.
  • getOwnerUsers - Gets the list of users for this owner, in escalation priority order if applicable.
  • setOwnerUsers - Sets the list of users for this owner. If escalation is enabled, the order of this list is the escalation priority order of the users. If the owner has a source group, adding or removing users from this list won't be possible.

requests

  • getRequests - Returns a list of requests for your organization that is visible by the admin.
  • createRequest - Create an access request
  • getRequestsRelay - Returns a paginated list of requests using Relay-style cursor pagination. :warning: Deprecated
  • getRequest - Returns a request by ID.
  • approveRequest - Approve an access request

resources

scopedRolePermissions

sessions

  • sessions - Returns a list of Session objects.

tags

uars

  • getUARs - Returns a list of UAR objects.
  • createUar - Starts a User Access Review.
  • getUar - Retrieves a specific UAR.

users

  • user - Retrieves detailed user information from Opal. This endpoint is designed to fetch user details by either user ID (UUID) or email address. The endpoint follows a strict precedence rule where user_id takes priority over email if both are provided.

Key Implementation Notes:

  • Exactly one identifier (user_id OR email) must be provided
  • Returns a complete User object with all associated metadata
  • Suitable for user verification and profile data retrieval
  • Recommended for MCP user synchronization workflows

Authentication:

  • Requires valid API authentication
  • Respects standard Opal authorization rules
  • getUsers - Returns a list of users for your organization.
  • getUserTags - Returns all tags applied to the user.

</details> <!-- End Available Resources and Operations [operations] -->

<!-- No Standalone functions [standalone-funcs] -->

<!-- No Retries [retries] -->

<!-- No Error Handling [errors] -->

<!-- No Server Selection [server] -->

<!-- No Custom HTTP Client [http-client] -->

<!-- No Debugging [debug] -->

<!-- Start Pagination [pagination] -->

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will also be an async iterable that can be consumed using the for await...of syntax.

Here's an example of one such pagination call:

import { OpalMcp } from "opal-mcp";

const opalMcp = new OpalMcp({
  bearerAuth: process.env["OPALMCP_BEARER_AUTH"] ?? "",
});

async function run() {
  const result = await opalMcp.bundles.getBundles({
    pageSize: 200,
    cursor: "cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw",
    contains: "Engineering",
  });

  for await (const page of result) {
    console.log(page);
  }
}

run();

<!-- End Pagination [pagination] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

See CONTRIBUTING.md for guidelines on contributing to this project.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选