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.5.0.tar.gz (33.8 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.5.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xiyan_table_mcp_server-0.5.0.tar.gz
  • Upload date:
  • Size: 33.8 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.5.0.tar.gz
Algorithm Hash digest
SHA256 522c52702d0fb8b904fcb8d219de53eb2deb08161fc07917dff0c1c987dbf6e3
MD5 72dfa71dcbe121cd68b3e69aabcefd07
BLAKE2b-256 51f665390828ce510f023d11de794a05723ca1526b4940bdfbc32c9677f78848

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xiyan_table_mcp_server-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7760436ea861ecc5406a6f4c48cafb6e268abe1655c7d9fbd6f414d3e11df9b
MD5 13f96f11779f00dc3ad9387b8972e168
BLAKE2b-256 e7489eb66f970b55aaac100865a34083eff596fea5ee56d76077ca19e0e53425

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