Access AskTable via MCP
This document introduces how to perform database query tasks through the MCP (Model Context Protocol AskTable) and based on natural language. It is suitable for Online SaaS users and on-premises deployment users.

Tool Introduction

-
List all data in AskTable - Get information about all available databases (data sources) under the current APIKEY.
- Input Example: What data sources do I have in my database?
- Usage Scenario: View all data sources under user permissions and obtain data source IDs for subsequent queries.
-
Query data using AskTable - Return actual data results directly based on user questions.
- Input Examples:
- "Please give me the top 10 products by sales"
- "What was the total order amount yesterday?"
- "How many employees are there in each department?"
- Input Examples:
-
Generate SQL using AskTable - Generate corresponding SQL statements based on user queries.
- Input Examples:
- "Generate an SQL that finds the top 10 products by sales"
- "I need the SQL to query the total order amount from yesterday"
- "SQL to count the number of employees in each department"
- Input Examples:
Use Case

User Configuration Guide
Method One: SaaS SSE Mode (Recommended for New Users)
If you are using the AskTable SaaS service, it is recommended to use the SSE method, which does not require installing any software.
You can directly access https://mcp.asktable.com to get more information!
-
Get AskTable API Key and Data Source ID
- Log in to AskTable
- Obtain your API key (apikey) in the settings
- Select the data source you want to connect to and obtain the data source ID (datasource_id)
-
Configure MCP Client (Recommended SSE Method)
{
"mcpServers": {
"asktable": {
"type": "sse",
"url": "https://mcp.asktable.com/sse/?apikey=ASKER_8H8DRJCH6LT8HCJPXOH4&datasource_id=ds_6iewvP4cpSyhO76P2Tv8MW",
"headers": {},
"timeout": 300,
"sse_read_timeout": 300
}
}
}Note: The apikey and datasource_id in the above URL are from the demo project and data on the AskTable.com official website, which can be used directly for testing. For example, ask "how many students are there in total?"
-
Start Using
- Restart your MCP client
- Now you can use all features of AskTable!
Method Two: SaaS Stdio Mode (Requires Installation Package)
If you are using the AskTable SaaS service but prefer the Stdio mode.
1. Install the package
# Install using uv
uvx asktable-mcp-server@latest
2. Configure the MCP client
{
"mcpServers": {
"asktable": {
"command": "uvx",
"args": ["asktable-mcp-server@latest"],
"env": {
"API_KEY": "ASKER_8H8DRJCH6LT8HCJPXOH4",
"DATASOURCE_ID": "ds_6iewvP4cpSyhO76P2Tv8MW"
}
}
}
}
Environment Variable Description:
API_KEY
: AskTable API key (required)DATASOURCE_ID
: AskTable data source ID (required)
Method Three: Local Deployment SSE Mode
If you are using the local deployment version of AskTable, it is recommended to use the SSE method. The MCP SSE Server is already included in the AskTable All-in-One image.
Directly access the local deployed AskTable at http://your_local_asktable_host:port/mcp
to learn more.
Configure the MCP client
{
"mcpServers": {
"asktable": {
"type": "sse",
"url": "http://your_local_asktable_host:port/mcp/sse/?apikey=your_api_key&datasource_id=your_datasource_id",
"headers": {},
"timeout": 300,
"sse_read_timeout": 300
}
}
}
Parameter Description:
apikey
: AskTable API key (required)datasource_id
: AskTable data source ID (required)
Method Four: Local Deployment Stdio Mode (Requires Installation Package)
If you are using a local deployment but prefer the Stdio mode, you need to install the package locally and configure the base_url.
1. Install the package
# Install using uv
uvx asktable-mcp-server@latest
2. Configure the MCP client
{
"mcpServers": {
"asktable": {
"command": "uvx",
"args": ["asktable-mcp-server@latest"],
"env": {
"API_KEY": "your_api_key",
"DATASOURCE_ID": "your_datasource_id",
"BASE_URL": "http://your_local_asktable_host:port/api"
}
}
}
}
Environment Variable Description:
API_KEY
: AskTable API key (required)DATASOURCE_ID
: AskTable data source ID (required)BASE_URL
: AskTable API address for local deployment (required as it's accessing the local deployed AskTable)
Self-hosted SSE Service (Advanced Users)
Docker Deployment (Recommended)
Use Official Image
# Pull the image
docker pull registry.cn-shanghai.aliyuncs.com/datamini/asktable-mcp-server:latest
# Run the container
docker run -d \
-p 8095:8095 \
-e BASE_URL=http://your_local_ip:port/api \
registry.cn-shanghai.aliyuncs.com/datamini/asktable-mcp-server:latest
Environment Variable Description:
BASE_URL
: AskTable API address for local deployment (optional)
For further assistance, please contact us.