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:
- Discover available tools and resources
- Invoke tools to fetch ServiceNex data
- 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
- Clone the repository:
git clone <repository-url>
cd servicenex-mcp-server
- 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
ensurepipnot being available (common on Debian/Ubuntu), first install the venv package:sudo apt install python3.12-venvThen recreate the virtual environment.
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_servicenex-0.1.2.tar.gz.
File metadata
- Download URL: mcp_servicenex-0.1.2.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e7a67a88dfcf7e1f6e28692d6c5915ffa8c1004bcb518cb4a891aa3047d1205
|
|
| MD5 |
39b3ec7c5b9f0b6ab44f24c549d2d57b
|
|
| BLAKE2b-256 |
0313e4735975dba9b8540c186577f05ae5418bc2884ea549fc8fdf5995ea619a
|
File details
Details for the file mcp_servicenex-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mcp_servicenex-0.1.2-py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db704f2bc7babb8dcc6346aca5dfb77353533113f3936bcd617c23c78b8bc533
|
|
| MD5 |
d765724e90adfc07a7b27d1181d252c1
|
|
| BLAKE2b-256 |
f8e56c88c919cbb1e8d865cb202493a9f0b730e376035119b636dab8b17be06b
|