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
- Clone the repository:
git clone https://github.com/yourusername/xiyan-table-mcp-server.git
cd xiyan-table-mcp-server
- Install dependencies:
pip install -r requirements.txt
Configuration
- Copy the example configuration file:
cp config.yml.example config.yml
- Edit
config.ymlwith 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
- Start the server:
python server.py
- 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
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- 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
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 xiyan_table_mcp_server-0.3.0.tar.gz.
File metadata
- Download URL: xiyan_table_mcp_server-0.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bbb22214b441ad2844da6320e2cf775b698213075b195f2467800bacf729dcf
|
|
| MD5 |
8cb146287a0a83953de19ee29487c23c
|
|
| BLAKE2b-256 |
f7ad95d4fc40ec9326f2a02a65dca279ce6d8d1f4d27e664b9db76916268e877
|
File details
Details for the file xiyan_table_mcp_server-0.3.0-py3-none-any.whl.
File metadata
- Download URL: xiyan_table_mcp_server-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29213aa4e0aac3fa69297f345098d8bbbae3ca04ae7b2260eb7fea31246e03be
|
|
| MD5 |
4ed544d5d93d3a2da685ddd04ca345be
|
|
| BLAKE2b-256 |
a4195486966e6a56c7fb2bf7e2c9841804d4d2ae61cb39af82ca317e0116270f
|