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.4.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.4.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xiyan_table_mcp_server-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 0b13c28c3c2df1876198c88cb8effb8aee4cd46acdf48c9b46c14ed439d5283f
MD5 3b14ad840099b7b40be175f7d2eab87a
BLAKE2b-256 c2a9e396ca6a2170087f806267ddf078c47d7fc0b16726980935e2a9fbdb3f35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xiyan_table_mcp_server-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1a9acbb2793dfa4fd034f1c1b7f5b7da19ef2640922321e7a21106ea193a4a0
MD5 49d93f895bc33a1d7ea3bf4681753d2f
BLAKE2b-256 4e9b36b748ea8c3dfde175d8f9aa0939ec734792712c16602fafcd8f970d1e80

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