Skip to main content

MCP server for LogicMonitor platform API integration

Project description

LogicMonitor MCP Server

Model Context Protocol (MCP) server for LogicMonitor REST API v3 integration. Enables AI assistants to interact with LogicMonitor monitoring data through structured tools.

Architecture

src/lm_mcp/
├── __init__.py      # Package exports
├── config.py        # Environment-based configuration (Pydantic)
├── exceptions.py    # Exception hierarchy with error codes
├── auth/
│   ├── __init__.py  # AuthProvider ABC and factory
│   └── bearer.py    # Bearer token implementation
└── client/
    ├── __init__.py  # Client exports
    └── api.py       # Async HTTP client (httpx)

Installation

Requires Python 3.11+ and uv package manager.

# Clone repository
git clone https://github.com/ryanmat/mcp-server-logicmonitor.git
cd mcp-server-logicmonitor

# Install dependencies
uv sync

Configuration

Copy .env.example to .env and configure:

LM_PORTAL=yourcompany.logicmonitor.com
LM_BEARER_TOKEN=your_bearer_token_here
LM_API_VERSION=3
LM_TIMEOUT=30

Configuration is loaded via Pydantic settings. All LM_ prefixed environment variables are automatically mapped.

Usage

API Client

import asyncio
from lm_mcp.config import LMConfig
from lm_mcp.auth import create_auth_provider
from lm_mcp.client import LogicMonitorClient

async def main():
    config = LMConfig()
    auth = create_auth_provider(config)

    async with LogicMonitorClient(
        base_url=config.base_url,
        auth=auth,
        timeout=config.timeout,
        api_version=config.api_version,
    ) as client:
        # Get alerts
        alerts = await client.get("/alert/alerts", params={"size": 10})
        print(f"Total alerts: {alerts['total']}")

        # Get devices
        devices = await client.get("/device/devices", params={"size": 5})
        print(f"Total devices: {devices['total']}")

asyncio.run(main())

Exception Handling

from lm_mcp.exceptions import (
    AuthenticationError,
    RateLimitError,
    NotFoundError,
)

try:
    result = await client.get("/device/devices/999")
except NotFoundError as e:
    print(f"Device not found: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after} seconds")
except AuthenticationError as e:
    print(f"Auth failed: {e}")

Development

Running Tests

uv run pytest -v

Linting

uv run ruff check src tests
uv run ruff format src tests

Project Structure

  • src/lm_mcp/ - Source code
  • tests/ - Unit and integration tests
  • docs/ - Implementation plans and specifications

API Reference

LogicMonitorClient

Async HTTP client supporting GET, POST, PUT, PATCH, DELETE methods.

Method Description
get(path, params) GET request with optional query params
post(path, json_body) POST request with JSON body
put(path, json_body) PUT request with JSON body
patch(path, json_body) PATCH request with JSON body
delete(path, params) DELETE request with optional params

Exception Hierarchy

Exception HTTP Status Code
LMError Base class LM_ERROR
ConfigurationError N/A CONFIGURATION_ERROR
AuthenticationError 401 AUTHENTICATION_ERROR
LMPermissionError 403 PERMISSION_ERROR
NotFoundError 404 NOT_FOUND_ERROR
RateLimitError 429 RATE_LIMIT_ERROR
ServerError 5xx SERVER_ERROR
LMConnectionError N/A CONNECTION_ERROR

License

See LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lm_mcp-0.1.0.tar.gz (68.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lm_mcp-0.1.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file lm_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: lm_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 68.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lm_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 db148b6055fe0c91f2902e2d35f609bd6b24432e9dad191a5fc0f87583e08a5a
MD5 453efb0fd67c2be3877b21341593a819
BLAKE2b-256 d5fff782df01c60b747f53ba0cedcb13b668a237b2a9237a5f2e61bb9c3bb17a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lm_mcp-0.1.0.tar.gz:

Publisher: release.yml on ryanmat/mcp-server-logicmonitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lm_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lm_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lm_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae754e656423e0d5860211509ca57d9205acc111305349b0f520c4b456f9e2ba
MD5 b3c0ec62e4e2c3d7493b2dff0137d82d
BLAKE2b-256 27f57f451e8e4cbcb8be32c29b170c2edfcfc4b8a034f532654b4624d4732c29

See more details on using hashes here.

Provenance

The following attestation bundles were made for lm_mcp-0.1.0-py3-none-any.whl:

Publisher: release.yml on ryanmat/mcp-server-logicmonitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page