Skip to main content

A Model Context Protocol (MCP) server that allows AI assistants to display table contents and perform natural language queries.

Project description

Xiyan Table MCP Server

A Model Control Protocol (MCP) server for table data querying that allows users to configure local table data and query it using natural language.

Features

  • Local CSV file configuration and reading
  • Table data preview functionality (first 20 rows)
  • Natural language querying support
  • Intelligent responses powered by Large Language Models
  • Flexible configuration using YAML
  • Easy-to-use MCP tools and resources

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/xiyan-table-mcp-server.git
cd xiyan-table-mcp-server
  1. Install dependencies:
pip install -r requirements.txt

Configuration

  1. Copy the example configuration file:
cp config.yml.example config.yml
  1. Edit config.yml with your settings:
table:
  path: "data/example.csv"  # Path to your CSV file
  encoding: "utf-8"         # File encoding
  preview_rows: 20          # Number of preview rows

model:
  type: "openai"           # Model type
  api_key: ""             # Your API key
  model_name: "gpt-4"     # Model name
  temperature: 0.1        # Temperature parameter

server:
  name: "xiyan-table"     # Server name
  version: "0.1.0"        # Version number

Usage

  1. Start the server:
python server.py
  1. Connect using an MCP client:
from mcp.client import MCPClient

# Connect to the server
client = MCPClient()

# Get table preview
preview = client.get_table_preview()
print(f"Table columns: {preview['columns']}")
print(f"Preview rows: {preview['preview_rows']}")

# Query data
result = client.query_table("What is the total number of rows in the table?")
print(f"Query result: {result}")

API Reference

Resources

get_table_preview

Returns a preview of the table data.

Response format:

{
    "columns": List[str],        # Column names
    "data": List[List[Any]],     # Table data
    "total_rows": int,           # Total number of rows
    "preview_rows": int          # Number of preview rows
}

Tools

query_table

Query the table using natural language.

Parameters:

  • question (str): The natural language query

Returns:

  • String response containing the answer to the query

Development

Requirements

  • Python 3.8+
  • pandas
  • pyyaml
  • openai
  • mcp-core

Project Structure

xiyan-table-mcp-server/
├── config.yml          # Configuration file
├── server.py          # Main server implementation
├── requirements.txt   # Project dependencies
└── README.md         # Documentation

License

MIT License

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

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

xiyan_table_mcp_server-0.6.0.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

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

xiyan_table_mcp_server-0.6.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file xiyan_table_mcp_server-0.6.0.tar.gz.

File metadata

  • Download URL: xiyan_table_mcp_server-0.6.0.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for xiyan_table_mcp_server-0.6.0.tar.gz
Algorithm Hash digest
SHA256 c3ece8c601449911f8c2b4eaff8ef43c73b50d0b4b4fd6a8b15cc4a8cd959250
MD5 af6880567c09c0a0366abeb654de9152
BLAKE2b-256 4f99aef2a38532ed0548f59afb2a0a6048006fd127f6544ba29c3c3681c241f0

See more details on using hashes here.

File details

Details for the file xiyan_table_mcp_server-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xiyan_table_mcp_server-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae31b75d839cab59e7b4d81b9c55def52e026d5551b0307c46ab8302f431cb55
MD5 d1fd6091eed32926ac5d60ef9eed3813
BLAKE2b-256 ca99e6950398ac7af2a2df2346d23b83f993700b4507e556d8483032b0b099d6

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