loading…
Search for a command to run...
loading…
Enables AI agents to securely query VAST Data databases for schema, metadata, and sample data via read-only SQL and MCP resources.
Enables AI agents to securely query VAST Data databases for schema, metadata, and sample data via read-only SQL and MCP resources.
This project implements a Model Context Protocol (MCP) server designed to act as an interface between AI agents/LLMs and a VAST Data database.
To provide a secure and structured way for AI models to query information (schema, data samples) and execute read-only queries against a VAST DB instance using the MCP standard.
mcp-sdk)vastdb)uvicornFastMCP from the mcp-sdkpython-dotenvpytest, pytest-asyncio, pytest-mock, httpxslowapi/
├── sdk/ # Cloned SDKs (ignored by git)
│ ├── python-sdk/
│ └── vastdb_sdk/
├── src/
│ └── vast_mcp_server/ # Main Python package
│ ├── __init__.py
│ ├── server.py # FastMCP application setup
│ ├── config.py # Loads connection details from .env
│ ├── utils.py # Shared utility functions (e.g., auth header extraction)
│ ├── resources/ # MCP Resource handlers
│ │ ├── __init__.py
│ │ ├── schema.py # Handler for vast://schemas
│ │ ├── table_data.py # Handler for vast://tables/{table_name}
│ │ └── metadata.py # Handler for vast://metadata/tables/{table_name}
│ ├── tools/ # MCP Tool handlers
│ │ ├── __init__.py
│ │ └── query.py # Handler for vast_sql_query tool
│ └── vast_integration/ # VAST DB interaction logic
│ ├── __init__.py
│ └── db_ops.py # Connection & query execution (async wrappers)
├── tests/ # Pytest unit/integration tests
│ ├── __init__.py
│ ├── test_db_ops.py # Tests for VAST DB interaction logic
│ ├── test_resources.py # Tests for MCP resource handlers
│ └── test_tools.py # Tests for MCP tool handlers
├── scripts/
│ └── run_server.py # Script to start the server via uvicorn
├── .gitignore
├── .env.example # Example environment file
├── README.md # This file
└── pyproject.toml # Project metadata and dependencies
Authentication: All resources and tools require the following HTTP headers to be sent with the request:
X-Vast-Access-Key: Your VAST DB access key.X-Vast-Secret-Key: Your VAST DB secret key.
Failure to provide these headers, or providing invalid credentials, will result in an UNAUTHENTICATED (401) error response.Rate Limiting: All resource and tool handlers are rate-limited based on the client IP address. The default limit is configurable via the MCP_DEFAULT_RATE_LIMIT environment variable (e.g., "10/minute", see .env.example). Exceeding the limit will result in a 429 Too Many Requests error.
vast://schemasMcpResponse with an error status code (UNAUTHENTICATED, SERVICE_UNAVAILABLE, INTERNAL_SERVER_ERROR) and a plain text error message body (ERROR: [ErrorType] Message).vast://tables?format=FMTformat (string, optional, default: json): Output format (json or csv/'list'). csv or list returns a newline-separated string.McpResponse with an error status code (UNAUTHENTICATED, BAD_REQUEST, SERVICE_UNAVAILABLE, INTERNAL_SERVER_ERROR) and a formatted error body (JSON or plain text based on format).vast://metadata/tables/{table_name}is_nullable: e.g., 'YES'/'NO'), key information (key: e.g., 'PRI'), and default value (default). Fields beyond name/type might be null if not available from the database introspection.table_name (string) and columns (list of objects, each potentially with name, type, is_nullable, key, default keys).{
"table_name": "my_table",
"columns": [
{
"name": "id",
"type": "INTEGER",
"is_nullable": "NO",
"key": "PRI",
"default": null
},
{
"name": "data_column",
"type": "VARCHAR",
"is_nullable": "YES",
"key": "",
"default": "'Default Text'"
},
{
"name": "timestamp",
"type": "TIMESTAMP",
"is_nullable": "YES",
"key": null,
"default": null
}
]
}
McpResponse with an error status code (UNAUTHENTICATED, NOT_FOUND, BAD_REQUEST, SERVICE_UNAVAILABLE, INTERNAL_SERVER_ERROR) and a JSON error body ({\"error\": ...}).vast://tables/{table_name}?limit=N&format=FMTtable_name. Requires authentication headers.limit (integer, optional, default: 10): Maximum number of rows.format (string, optional, default: csv): Output format (csv or json).McpResponse with an error status code (UNAUTHENTICATED, BAD_REQUEST, SERVICE_UNAVAILABLE, INTERNAL_SERVER_ERROR) and a formatted error body (JSON or plain text based on format).vast_sql_querysql (string, required): The SQL query to execute.format (string, optional, default: csv): Output format (csv or json).headers (dict, required): Dictionary containing request headers, must include X-Vast-Access-Key and X-Vast-Secret-Key.headers argument.format).MCP_ALLOWED_SQL_TYPES env var (defaults to SELECT).AuthenticationError), disallowed query types (InvalidInputError), connection issues (DatabaseConnectionError), and query execution problems (QueryExecutionError).When integrating this MCP server with an AI agent framework (e.g., LangChain, LlamaIndex, custom agents), consider the following:
Agent Prompting/Configuration:
vast://schemas, vast://tables?..., vast://metadata/tables/{name}, vast://tables/{name}?....) and the tool name (vast_sql_query) with their capabilities.Authentication Handling (Security Critical):
access_key, secret_key) in prompts sent to the LLM.headers dictionary: {'X-Vast-Access-Key': '...', 'X-Vast-Secret-Key': '...'}.vast:// URI scheme to the actual HTTP URL of the running MCP server (e.g., http://localhost:8088/).headers.vast_sql_query tool and provides the sql and format arguments, the orchestrator must:headers dictionary as above.headers dictionary into the arguments passed to the tool execution function. The LLM should not generate the headers argument itself.Request Construction:
{table_name}) and query parameters (?format=, ?limit=) for resources.sql and format arguments for the vast_sql_query tool.Response Handling:
Content-Types (e.g., text/plain, application/json, text/csv).vast_sql_query tool. (Done - using sqlparse)extract_auth_headers, formatters) into utils.py. (Done).env.example to .env and fill in your VAST DB endpoint, access key, and secret key.cp .env.example .env
# Edit .env with your details
Выполни в терминале:
claude mcp add vast-db-mcp-server -- npx Query your database in natural language
автор: AnthropicRead-only database access with schema inspection.
автор: modelcontextprotocolInteract with Redis key-value stores.
автор: modelcontextprotocolDatabase interaction and business intelligence capabilities.
автор: modelcontextprotocolНе уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории data