Skip to main content

A Model Context Protocol (MCP) server for ServiceNex knowledge base articles and support tickets

Project description

servicenex-mcp-server

A Model Context Protocol (MCP) server that provides AI assistants with secure access to ServiceNex knowledge base articles and support tickets.

๐ŸŒŸ Features

  • MCP Tools: Execute actions like fetching articles, searching, and retrieving tickets
  • MCP Resources: Access knowledge base data through structured resource URIs
  • Real-time Data: Connect directly to ServiceNex API for live data
  • AI-Ready: Formatted responses optimized for AI assistant consumption

๐Ÿ—๏ธ Architecture

This server implements the Model Context Protocol (MCP), allowing AI assistants like Claude to:

  1. Discover available tools and resources
  2. Invoke tools to fetch ServiceNex data
  3. Access resources via URIs
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  AI Client  โ”‚ โ—„โ”€MCPโ”€โ”€โ–บโ”‚  MCP Server      โ”‚ โ—„โ”€APIโ”€โ”€โ–บโ”‚ ServiceNex  โ”‚
โ”‚  (Claude)   โ”‚         โ”‚  (This Project)  โ”‚         โ”‚  Platform   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Installation

Option 1: Using uvx (Recommended)

uvx allows you to run the MCP server without installing it globally. Install uv first:

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run the MCP server directly with uvx
uvx mcp-servicenex

No installation needed! uvx will automatically download and run the package when published.

Option 2: Install from PyPI

Alternatively, you can install the package globally:

pip install mcp-servicenex

Or using uv:

uv pip install mcp-servicenex

Option 3: Install from Source

  1. Clone the repository:
git clone <repository-url>
cd servicenex-mcp-server
  1. Create and activate virtual environment:
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

Note: If you encounter an error about ensurepip not being available (common on Debian/Ubuntu), first install the venv package:

sudo apt install python3.12-venv

Then recreate the virtual environment.

  1. Install in development mode:
pip install -e .

Or install dependencies directly:

pip install -r requirements.txt

Configuration

Configure API credentials via environment variables (recommended) or edit app/config.py:

Using environment variables (recommended):

export MY_API_BASE_URL="https://qa.servicenex.io/api"
export MY_API_KEY="your-api-key-here"

Or create a .env file (copy from .env.example):

cp .env.example .env
# Edit .env with your credentials

๐Ÿš€ Usage

Running the MCP Server

The MCP server uses stdio transport for communication with MCP clients:

Using uvx (Recommended):

uvx mcp-servicenex

If installed from PyPI:

mcp-servicenex

If installed from source:

# Activate virtual environment
source venv/bin/activate

# Run the MCP server
python -m app.mcp_server

Or use the convenience script:

./run_server.sh

Docker Deployment

Run the MCP server in Docker:

# Build and run
./docker-run.sh

# Or manually
docker build -t servicenex-mcp-server .
docker run -it --rm \
    -e MY_API_BASE_URL="https://qa.servicenex.io/api" \
    -e MY_API_KEY="your-api-key-here" \
    servicenex-mcp-server

Cloud Deployment

For persistent, remote deployment, see DEPLOYMENT.md for:

  • Google Compute Engine setup
  • Remote MCP via SSH
  • Production best practices

Available MCP Tools

1. get_knowledge_articles

Fetch knowledge base articles with optional limit.

Parameters:

  • limit (integer, optional): Maximum number of articles to return (default: 10)

Example Response:

๐Ÿ“š ServiceNex Knowledge Base
==================================================

Total Articles: 45 (Page 1 of 5)
Showing: 10 articles

1. Getting Started with ServiceNex
   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ID: 12345
   Category: Tutorials
   Author: John Doe
   Status: Published
   Created: 2024-01-15

2. get_tickets

Fetch recent support tickets.

Parameters:

  • limit (integer, optional): Maximum number of tickets to return (default: 5)

Example Response:

๐ŸŽซ Recent Support Tickets
==================================================

Found 5 recent tickets:

1. Cannot login to dashboard
   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ID: TKT-001
   Status: Open
   Priority: High
   Assignee: Support Team

3. search_articles

Search for articles by keyword.

Parameters:

  • query (string, required): Search query to find relevant articles

Example:

{
  "query": "authentication"
}

4. get_article_by_id

Get detailed information about a specific article.

Parameters:

  • article_id (string, required): The ID of the article to retrieve

Available MCP Resources

Resources provide direct access to data through URIs:

1. servicenex://articles/all

Complete list of published knowledge base articles in JSON format.

2. servicenex://tickets/recent

List of recent support tickets in JSON format.

๐Ÿ”Œ Integration with AI Assistants

Claude Desktop Integration

Add this server to your Claude Desktop configuration:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json

Using uvx (Recommended)

This is the recommended method - no installation needed:

{
  "mcpServers": {
    "servicenex": {
      "command": "uvx",
      "args": ["mcp-servicenex"],
      "env": {
        "MY_API_BASE_URL": "https://qa.servicenex.io/api",
        "MY_API_KEY": "your-api-key-here"
      }
    }
  }
}

Note: Make sure uv is installed. Install it with:

curl -LsSf https://astral.sh/uv/install.sh | sh

Standard Installation (PyPI)

If installed via pip install mcp-servicenex:

{
  "mcpServers": {
    "servicenex": {
      "command": "mcp-servicenex",
      "env": {
        "MY_API_BASE_URL": "https://qa.servicenex.io/api",
        "MY_API_KEY": "your-api-key-here"
      }
    }
  }
}

Local Python Installation (Development)

{
  "mcpServers": {
    "servicenex": {
      "command": "python",
      "args": ["-m", "app.mcp_server"],
      "cwd": "/path/to/servicenex-mcp-server",
      "env": {
        "PYTHONPATH": "/path/to/servicenex-mcp-server",
        "PATH": "/path/to/servicenex-mcp-server/venv/bin",
        "MY_API_BASE_URL": "https://qa.servicenex.io/api",
        "MY_API_KEY": "your-api-key-here"
      }
    }
  }
}

Docker Installation

{
  "mcpServers": {
    "servicenex": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "MY_API_BASE_URL=https://qa.servicenex.io/api",
        "-e",
        "MY_API_KEY=your-api-key-here",
        "servicenex-mcp-server"
      ]
    }
  }
}

Note: Replace /path/to/servicenex-mcp-server with your actual path and your-api-key-here with your ServiceNex API key.

Using with MCP Client

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

# Configure server parameters
server_params = StdioServerParameters(
    command="python",
    args=["-m", "app.mcp_server"],
    cwd="/path/to/servicenex-mcp-server"
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        # Initialize connection
        await session.initialize()
        
        # List available tools
        tools = await session.list_tools()
        print(f"Available tools: {[tool.name for tool in tools.tools]}")
        
        # Call a tool
        result = await session.call_tool(
            "get_knowledge_articles",
            arguments={"limit": 5}
        )
        print(result.content[0].text)

๐Ÿ“ Project Structure

servicenex-mcp-server/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ mcp_server.py        # MCP server (tools + resources)
โ”‚   โ”œโ”€โ”€ agent.py             # Legacy agent handlers (deprecated)
โ”‚   โ”œโ”€โ”€ config.py            # API configuration
โ”‚   โ””โ”€โ”€ loaders/
โ”‚       โ””โ”€โ”€ my_api_loader.py # ServiceNex API client
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ Dockerfile              # Docker container configuration
โ”œโ”€โ”€ docker-run.sh           # Docker deployment script
โ”œโ”€โ”€ deploy-gce.sh           # Google Compute Engine deployment
โ”œโ”€โ”€ DEPLOYMENT.md           # Detailed deployment guide
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ venv/                   # Virtual environment

๐Ÿ”ง Development

Adding New Tools

To add a new tool, update the list_tools() and call_tool() functions in app/mcp_server.py:

@app.list_tools()
async def list_tools() -> list[Tool]:
    return [
        # ... existing tools
        Tool(
            name="your_new_tool",
            description="Description of what your tool does",
            inputSchema={
                "type": "object",
                "properties": {
                    "param1": {
                        "type": "string",
                        "description": "Parameter description"
                    }
                },
                "required": ["param1"],
            },
        ),
    ]

@app.call_tool()
async def call_tool(name: str, arguments: Any) -> Sequence[TextContent]:
    if name == "your_new_tool":
        # Implement your tool logic here
        return [TextContent(type="text", text="Tool response")]

Adding New Resources

To add a new resource, update app/mcp_server.py:

@server.list_resources()
async def list_resources() -> list[Resource]:
    return [
        # ... existing resources
        Resource(
            uri="servicenex://your/resource",
            name="Your Resource Name",
            description="Resource description",
            mimeType="application/json",
        ),
    ]

@server.read_resource()
async def read_resource(uri: str) -> str:
    if uri == "servicenex://your/resource":
        # Fetch and return resource data
        return json.dumps(data)

๐Ÿ” Security

  • API Keys: Store sensitive credentials in environment variables or secure config files
  • Network: The MCP server communicates via stdio, not exposed network ports
  • Access Control: Implement proper authentication in the ServiceNex API layer

๐Ÿ“ License

[Add your license information here]

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“ง Support

For issues and questions:

  • Create an issue in this repository
  • Contact: [Your contact information]

๐Ÿ”— Related Links

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

mcp_servicenex-0.1.6.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

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

mcp_servicenex-0.1.6-py3-none-any.whl (54.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_servicenex-0.1.6.tar.gz.

File metadata

  • Download URL: mcp_servicenex-0.1.6.tar.gz
  • Upload date:
  • Size: 56.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mcp_servicenex-0.1.6.tar.gz
Algorithm Hash digest
SHA256 cf358c9dc1b9266a1c8623c15e08cad0d4c1c5eacbcace43fc39fd2cd29d0f8a
MD5 9d86e4196aed98b82001c2a2d230a805
BLAKE2b-256 3df6975bacb45b8a67edb63560ab424b34af6a1b6674dc707f0a6634b5fe74df

See more details on using hashes here.

File details

Details for the file mcp_servicenex-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: mcp_servicenex-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 54.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mcp_servicenex-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9d893c184e283ec4a31f3837ab9457d3c053c5afe540c096320b456045d5c253
MD5 a90c9a4097ff287634f260f615c8eb66
BLAKE2b-256 811cb4a8e358190c4facbb283c33c34d72f3e7a8d838caf714a2b776ee178837

See more details on using hashes here.

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