Skip to main content

Model Context Protocol (MCP) server for AI-driven ServiceNow table data export to XML attachments.

Project description

๐Ÿš€ ServiceNow MCP Server - AI-Powered Data Export Tool

Python Version MCP Compatible ServiceNow License: MIT Status

๐ŸŽฏ Transform ServiceNow data access with natural language commands

Export ServiceNow table data effortlessly using voice commands and AI - no complex APIs needed!

๐Ÿš€ Quick Start โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ’ก Examples โ€ข ๐Ÿค Contributing


๐Ÿ“‹ Table of Contents

๐ŸŒŸ Overview

The ServiceNow MCP Server is a cutting-edge Model Context Protocol server that revolutionizes how you interact with ServiceNow data. By combining the power of AI with intuitive natural language processing, this tool transforms complex ServiceNow API operations into simple conversational commands.

graph TD
    A[๐Ÿ‘ค User Voice Command] --> B[๐Ÿค– Claude AI]
    B --> C[๐Ÿ”ง MCP Server]
    C --> D[๐ŸŒ ServiceNow API]
    D --> E[๐Ÿ“Š Data Processing]
    E --> F[๐Ÿ“ File Export]
    F --> G[๐Ÿ’พ Downloads Folder]

๐ŸŽฏ Why Choose ServiceNow MCP Server?

  • ๐Ÿ—ฃ๏ธ Voice-Controlled: Use natural language commands instead of complex API calls
  • ๐Ÿง  AI-Powered: Intelligent table name resolution from conversational descriptions
  • โšก Lightning Fast: Optimized async operations for rapid data retrieval
  • ๐Ÿ”’ Secure: Built-in authentication and error handling
  • ๐Ÿ“ฑ Cross-Platform: Works on Windows, macOS, and Linux
  • ๐ŸŽจ Multiple Formats: Export to CSV, XML, or both simultaneously

โœจ Key Features

๐ŸŽค Natural Language Interface

  • Convert "export server data" to actual table queries
  • NEW: [table_name] bracket syntax support
  • Command: "Export data from Server[cmdb_ci_server] table"
  • Voice command support through Claude AI integration

๐Ÿ“Š Smart Data Export

  • Multiple export formats (CSV, XML, both)
  • XML format as default (per requirements)
  • Automatic file naming with timestamps
  • File attachment support for Claude AI

๐Ÿ”ง Advanced API Support

  • REST API integration (default)
  • SOAP API support (new)
  • ๐Ÿš€ UNLIMITED RECORD EXPORT - Handles millions of records
  • ๐Ÿ“Š Pagination and chunked processing for memory efficiency
  • Custom query filters with ServiceNow syntax
  • Field selection for targeted exports

๐Ÿ›ก๏ธ Enterprise Ready

  • Robust error handling and logging
  • Secure authentication with environment variables
  • Production-ready async architecture
  • Cross-platform file handling

๐Ÿ—๏ธ Architecture

๐Ÿ” Click to expand architecture details

System Components

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Claude AI     โ”‚โ”€โ”€โ”€โ–ถโ”‚   MCP Server     โ”‚โ”€โ”€โ”€โ–ถโ”‚   ServiceNow    โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข NL Processing โ”‚    โ”‚ โ€ข Table Mapping  โ”‚    โ”‚ โ€ข REST API      โ”‚
โ”‚ โ€ข Tool Calling  โ”‚    โ”‚ โ€ข Data Export    โ”‚    โ”‚ โ€ข Authenticationโ”‚
โ”‚ โ€ข User Interfaceโ”‚    โ”‚ โ€ข File Generationโ”‚    โ”‚ โ€ข Data Storage  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚
                                โ–ผ
                       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                       โ”‚ Local File Systemโ”‚
                       โ”‚                  โ”‚
                       โ”‚ โ€ข Downloads Folderโ”‚
                       โ”‚ โ€ข CSV/XML Files  โ”‚
                       โ”‚ โ€ข Auto Naming    โ”‚
                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Data Flow

  1. Input: User provides natural language command
  2. Processing: Claude AI interprets and calls appropriate MCP tool
  3. Resolution: MCP server resolves table names and builds queries
  4. Retrieval: Secure API calls to ServiceNow instance
  5. Transformation: Data converted to requested format(s)
  6. Output: Files saved to Downloads folder with confirmation

โšก Quick Start

๐Ÿš€ 1-Minute Setup

# Clone the repository
git clone https://github.com/yourusername/servicenow-mcp-server.git
cd servicenow-mcp-server

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your ServiceNow credentials

# Run the server
python main.py

๐ŸŽฏ First Export

Once configured, try these natural language commands:

"Export the server table"

"Get me incident data in XML format"

"Export users with both CSV and XML"

๐Ÿ”ง Installation

Prerequisites

Requirement Version Purpose
Python 3.8+ Runtime environment
ServiceNow Instance Any Data source
Claude AI Access Latest Natural language interface

Step-by-Step Installation

๐Ÿ“ฆ Detailed Installation Guide
  1. Clone Repository

    git clone https://github.com/yourusername/servicenow-mcp-server.git
    cd servicenow-mcp-server
    
  2. Create Virtual Environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install Dependencies

    pip install -r requirements.txt
    
  4. Environment Setup

    cp .env.example .env
    

    Edit .env file:

    SERVICENOW_INSTANCE=https://your-instance.service-now.com
    SERVICENOW_USERNAME=your_username
    SERVICENOW_PASSWORD=your_password
    
  5. Verify Installation

    python -c "import main; print('โœ… Installation successful!')"
    

Requirements

# Core dependencies
fastmcp>=0.1.0
httpx>=0.24.0
python-dotenv>=1.0.0

# Optional enhancements
rich>=13.0.0        # Better console output
typer>=0.9.0        # CLI interface
pytest>=7.0.0       # Testing framework

โš™๏ธ Configuration

Environment Variables

Variable Description Example Required
SERVICENOW_INSTANCE Your ServiceNow instance URL https://dev12345.service-now.com โœ…
SERVICENOW_USERNAME ServiceNow username admin โœ…
SERVICENOW_PASSWORD ServiceNow password your_password โœ…

๐ŸŽค Voice Commands

Command Result Format
"Export the server table" โžก๏ธ cmdb_ci_server_export.csv CSV
"Get incident data as XML" โžก๏ธ incident_export.xml XML
"Export users in both formats" โžก๏ธ Both CSV & XML files Both

๐Ÿ“ Detailed Examples

๐Ÿ” Click to see detailed examples

Basic Export

# Command: "Export the server table"
# Result: Downloads/cmdb_ci_server_export_20241201_143022.csv

Filtered Export

# Command: "Export active incidents from last week"
# Translates to query filter and exports matching records

Multi-Format Export

# Command: "Export user data in both CSV and XML"
# Creates:
# - Downloads/sys_user_export_20241201_143022.csv
# - Downloads/sys_user_export_20241201_143022.xml

Custom Fields

# Advanced usage through tool parameters:
# - table_description: "server table"
# - fields: "name,ip_address,sys_id"
# - max_records: 500

๐Ÿ”ง Primary Tools

Tool Purpose Input Output
export_servicenow_data ๐ŸŽฏ Main export with bracket syntax "[table_name] command" XML attachment
export_with_bracket_syntax ๐Ÿ“‹ Specialized bracket parser Bracket syntax command XML file
export_table_to_xml ๐Ÿ“„ Direct XML export Table name XML file
list_common_tables ๐Ÿ“‹ Show table mappings None Table reference

๐Ÿ†• New Features for Unlimited Data Export

1. Unlimited Record Processing

# Now handles ANY number of records - 10K, 100K, 1M+
"Export ALL data from Server[cmdb_ci_server] table"
# Automatically uses pagination to fetch ALL records

2. Memory-Efficient Processing

# Chunked processing prevents memory overload
# - Fetches data in 1000-record chunks
# - Processes CSV in 5000-record chunks
# - Progress tracking for large datasets

3. Performance Optimizations

# Smart processing based on dataset size
# - Small datasets: Direct processing
# - Large datasets: Chunked processing with progress tracking
# - Memory management and garbage collection

4. Enterprise-Scale Support

# Production-ready for enterprise environments
# - Handles ServiceNow instances with millions of records
# - Automatic pagination and memory management
# - Robust error handling and recovery

๐Ÿ”’ Authentication

๐Ÿ›ก๏ธ Security Best Practices

โœ… Recommended โŒ Avoid
Environment variables Hardcoded credentials
Dedicated service account Personal accounts
Minimal required permissions Admin privileges
Regular password rotation Static passwords

ServiceNow Permissions

Required roles and permissions:

  • rest_service - Access REST APIs
  • table_reader - Read table data
  • Read access to target tables (e.g., cmdb_ci_server, incident)
  • itil - For incident management tables
๐Ÿ”ง Detailed Permission Setup
  1. Create Service Account

    Navigate to: User Administration > Users
    Create new user with appropriate roles
    
  2. Assign Roles

    Required roles:
    - rest_service
    - table_reader
    - Custom roles for specific tables if needed
    
  3. Test Access

    curl -u username:password \
      "https://your-instance.service-now.com/api/now/table/incident?sysparm_limit=1"
    

๐Ÿ› Troubleshooting

๐Ÿ” Common Issues

โŒ Authentication Errors

Problem: HTTP 401 Unauthorized

Solutions:

  • โœ… Verify credentials in .env file
  • โœ… Check ServiceNow instance URL format
  • โœ… Ensure account has required roles
  • โœ… Test with ServiceNow's REST API Explorer
โŒ Table Not Found

Problem: Table 'xyz' doesn't exist

Solutions:

  • โœ… Use list_common_tables tool to see available mappings
  • โœ… Check table name spelling
  • โœ… Verify table exists in your instance
  • โœ… Ensure read permissions on the table
โŒ Export Failures

Problem: Export process fails or incomplete

Solutions:

  • โœ… Check network connectivity
  • โœ… Reduce max_records parameter
  • โœ… Verify Downloads folder permissions
  • โœ… Review ServiceNow instance performance

๐Ÿ”ง Debug Mode

Enable detailed logging:

export DEBUG=1
python main.py

๐Ÿ“ž Support

Need help? Check these resources:

๐Ÿ“‹ Development Setup

๐Ÿ”ง Development Environment Setup
# Clone and setup
git clone https://github.com/yourusername/servicenow-mcp-server.git
cd servicenow-mcp-server

# Development environment
python -m venv dev-env
source dev-env/bin/activate  # Windows: dev-env\Scripts\activate

# Install dev dependencies
uv sync

๐Ÿ“„ License

This project is licensed under the MIT License.

License: MIT

See the LICENSE file for details.


๐ŸŒŸ Made with โค๏ธ by Divya Shah

โญ Star this repo โ€ข ๐Ÿ› Report Bug โ€ข โœจ Request Feature


Connect with me:

GitHub LinkedIn Twitter

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_server_table-0.1.0.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

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

mcp_server_table-0.1.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mcp_server_table-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb9225b078cc3706fa2d841100b1764890cfc2b8bd933df4875b0f214a20bd7b
MD5 d4659f8e08bdb3ecd40080753a7e4eb4
BLAKE2b-256 4e7457af0177081284f1f09ddb95ba2f68dd758d47354081a17a3424d9174980

See more details on using hashes here.

Provenance

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

Publisher: publish-to-pypi.yml on divyashah0510/mcp-servicenow-exporter

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

File details

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

File metadata

File hashes

Hashes for mcp_server_table-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0002c711815e8be70fb33fd2f926a0d2caa77c5145cf15f4c202df8d28eff8df
MD5 890e6f59a81e3105c0f9d621769e8fa8
BLAKE2b-256 f775acafe9e09206cb0799f9e5d13263975f019f1575f668448daf7f26eba38b

See more details on using hashes here.

Provenance

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

Publisher: publish-to-pypi.yml on divyashah0510/mcp-servicenow-exporter

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