Skip to main content
Glama
bpamiri
by bpamiri

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MSSQL_HOSTYesSQL Server hostname
MSSQL_PORTNoServer port1433
MSSQL_USERYesDatabase username
MSSQL_DATABASEYesDatabase name
MSSQL_MAX_ROWSNoQuery row limit1000
MSSQL_PASSWORDYesDatabase password
MSSQL_READ_ONLYNoBlock write operationsfalse
MSSQL_QUERY_TIMEOUTNoQuery timeout (seconds)60

Tools

Functions exposed to the LLM to take actions

NameDescription
connect

Establish connection to the SQL Server database.

Uses configuration from environment variables: - MSSQL_HOST: Server hostname or IP - MSSQL_USER: Username - MSSQL_PASSWORD: Password - MSSQL_DATABASE: Database name - MSSQL_PORT: Port (default: 1433) Returns: Connection status and details including host, database, and timestamp.
disconnect

Close all connections to the SQL Server database.

Returns: Disconnection status and count of closed connections.
list_connections

List all active database connections.

Returns: List of active connections with their details (name, host, database, connection time, and active status).
read_rows

Read rows from a table by primary key or filter.

Provide one of: id (single row), ids (multiple rows), or filter (WHERE clause). Args: table: Table name (can include schema: 'dbo.Users' or 'Users') id: Single primary key value (for composite keys, use filter) ids: List of primary key values filter: WHERE clause without 'WHERE' keyword (e.g., "status = 'active'") columns: List of columns to return (default: all columns) max_rows: Maximum rows to return Returns: Dictionary with: - table: Full table name - rows: List of row dictionaries - count: Number of rows returned
insert_row

Insert a new row into a table.

Args: table: Table name (can include schema: 'dbo.Users' or 'Users') data: Dictionary of column names and values to insert Returns: Dictionary with: - status: 'success' or error - table: Full table name - inserted: The inserted row (including generated identity columns)
update_row

Update an existing row by primary key.

Args: table: Table name (can include schema: 'dbo.Users' or 'Users') id: Primary key value of the row to update data: Dictionary of column names and new values Returns: Dictionary with: - status: 'success' or error - table: Full table name - updated: The updated row
delete_row

Delete a row by primary key.

Args: table: Table name (can include schema: 'dbo.Users' or 'Users') id: Primary key value of the row to delete Returns: Dictionary with: - status: 'deleted' or error - table: Full table name - id: The deleted row's ID - rows_affected: Number of rows deleted (should be 1)
list_databases

List all available databases on the SQL Server.

Queries sys.databases to discover accessible databases. System databases (master, tempdb, model, msdb) are excluded by default. Databases in the blocklist (MSSQL_BLOCKED_DATABASES) are always excluded. Args: include_system: If True, include system databases in the list Returns: Dictionary with: - databases: List of available database names - current_database: The currently active database - count: Number of databases returned - blocked_count: Number of databases hidden due to blocklist
switch_database

Switch the active database context.

Changes the current database using the USE statement. The database must exist, be online, and not be in the blocklist (MSSQL_BLOCKED_DATABASES). Args: database_name: Name of the database to switch to Returns: Dictionary with: - status: "switched" on success, "error" on failure - database: The new active database name - previous_database: The previously active database - error: Error message if switch failed
export_to_json

Export query results to a JSON file.

Args: query: SQL SELECT query to execute filename: Output filename (relative or absolute path) Returns: Dictionary with: - status: 'success' or error - path: Absolute path to created file - row_count: Number of rows exported - file_size: Size of created file in bytes
export_to_csv

Export query results to a CSV file.

Args: query: SQL SELECT query to execute filename: Output filename (relative or absolute path) delimiter: Field delimiter (default: comma) Returns: Dictionary with: - status: 'success' or error - path: Absolute path to created file - row_count: Number of rows exported - file_size: Size of created file in bytes
execute_query

Execute a read-only SQL query and return results.

Only SELECT statements are allowed. The query will have a row limit applied automatically if not specified. Args: query: SQL SELECT statement to execute max_rows: Maximum rows to return (overrides default, capped by MSSQL_MAX_ROWS) Returns: Dictionary with: - query: The original query - executed_query: The query that was actually executed (may include TOP) - columns: List of column names - rows: List of row dictionaries - row_count: Number of rows returned - max_rows: The effective row limit applied
validate_query

Check if a query is safe to execute without running it.

Validates the query against: - Statement type (SELECT, INSERT, UPDATE, DELETE, DDL, EXEC) - Blocked commands list - Read-only mode compliance - Potential issues (missing WHERE clause, unbounded SELECT) Args: query: SQL statement to validate Returns: Dictionary with: - query: The original query - valid: Whether the query is valid - statement_type: Type of SQL statement - warnings: List of warning messages - suggestions: List of suggested improvements - error: Error message if invalid
list_stored_procs

List available stored procedures in the database.

Args: schema: Filter by schema name (e.g., 'dbo') pattern: Filter by name pattern using SQL LIKE syntax (e.g., 'sp_%', '%User%') Returns: Dictionary with: - procedures: List of procedure info (schema, name, created, modified) - count: Number of procedures found
describe_stored_proc

Get parameter information for a stored procedure.

Args: procedure: Procedure name, optionally with schema (e.g., 'dbo.sp_GetUser' or 'sp_GetUser') Returns: Dictionary with: - procedure: Full procedure name (schema.name) - parameters: List of parameter info (name, type, direction, etc.)
call_stored_proc

Execute a stored procedure.

Args: procedure: Procedure name, optionally with schema (e.g., 'dbo.sp_GetUser' or 'sp_GetUser') params: Input parameter values as dictionary (parameter names without @) Returns: Dictionary with: - procedure: Full procedure name - result_sets: List of result sets (each is a list of row dictionaries) - status: 'success' or error
list_tables

List all tables and views in the database.

Args: schema: Filter by schema name (e.g., 'dbo'). If not specified, returns all schemas. include_views: Include views in results (default: True) pattern: Filter by name pattern using SQL LIKE syntax (e.g., 'Cust%', '%Order%') Returns: Dictionary with: - tables: List of table/view info (schema, name, type) - count: Number of results
describe_table

Get detailed column information for a table.

Retrieves column definitions, primary keys, foreign keys, and indexes. Args: table: Table name, optionally with schema (e.g., 'dbo.Users' or 'Users'). Defaults to 'dbo' schema if not specified. Returns: Dictionary with: - table: Full table name (schema.table) - columns: List of column info (name, type, nullable, etc.) - primary_key: List of primary key column names - foreign_keys: List of foreign key relationships - indexes: List of index info

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription
get_tsql_syntaxT-SQL syntax reference for SQL Server queries. Provides a quick reference for T-SQL query syntax, including SELECT, WHERE, JOIN, aggregation functions, and common data types.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bpamiri/pymssql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server