io.github.daedalus/mcp-server-mssql
MCP server for Microsoft SQL Server using mssql-python
Versions
0.1.0latestTools 21
connect_tool Connect to Microsoft SQL Server using the provided connection string. Args: connection_string: SQL Server connection string in semicolon-delimited key=value format (e.g., "SERVER=tcp:localhost;DATABASE=mydb;Authentication=ActiveDirectoryInteractive;Encrypt=yes;") Returns: Dictionary containing connection_id and server info. The connection_id should be used for subsequent operations. Example: >>> connect_tool("SERVER=localhost;DATABASE=TestDB;UID=sa;PWD=password;") {"connection_id": "abc123", "server_name": "localhost", "database": "TestDB"}
close_connection Close an existing database connection. Args: connection_id: The ID returned from connect_tool Returns: Dictionary with status confirmation. Example: >>> close_connection("abc123") {"status": "closed", "connection_id": "abc123"}
list_connections List all active connections. Returns: List of connection info dictionaries. Example: >>> list_connections() [{"connection_id": "abc123", "server": "localhost", "database": "TestDB"}]
execute_query Execute a SQL query and return results. Args: connection_id: The ID returned from connect_tool sql: SQL statement to execute params: Optional list of parameters for parameterized query Returns: List of row dictionaries. Example: >>> execute_query("abc123", "SELECT * FROM users WHERE active = 1") [{"id": 1, "name": "John", "active": true}, {"id": 2, "name": "Jane", "active": true}]
execute_scalar Execute a SQL query and return a single value. Args: connection_id: The ID returned from connect_tool sql: SQL statement that returns a single value Returns: The single value from the query result. Example: >>> execute_scalar("abc123", "SELECT COUNT(*) FROM users") 42
fetch_results Fetch results from an existing cursor. Args: connection_id: The ID returned from connect_tool cursor_id: The cursor ID from execute_query mode: Fetch mode - "one", "many", or "all" (default: "all") size: Number of rows for "many" mode Returns: List of row dictionaries. Example: >>> fetch_results("abc123", "cursor123", mode="many", size=10) [{"id": 1, "name": "John"}, {"id": 2, "name": "Jane"}]
call_procedure Call a stored procedure. Args: connection_id: The ID returned from connect_tool procedure_name: Name of the stored procedure params: Optional list of parameters Returns: Dictionary with procedure results. Example: >>> call_procedure("abc123", "sp_GetUsers", [1]) {"result": [{"id": 1, "name": "John"}]}
commit Commit the current transaction. Args: connection_id: The ID returned from connect_tool Returns: Dictionary with status confirmation. Example: >>> commit("abc123") {"status": "committed", "connection_id": "abc123"}
rollback Rollback the current transaction. Args: connection_id: The ID returned from connect_tool Returns: Dictionary with status confirmation. Example: >>> rollback("abc123") {"status": "rolled_back", "connection_id": "abc123"}
set_autocommit Set autocommit mode for a connection. Args: connection_id: The ID returned from connect_tool enabled: Whether to enable autocommit Returns: Dictionary with status confirmation. Example: >>> set_autocommit("abc123", True) {"status": "set", "autocommit": true}
bulk_copy Perform a bulk copy operation to load data into a table. Args: connection_id: The ID returned from connect_tool table_name: Target table name data: List of tuples or lists representing rows to insert column_mappings: Optional list of column mappings batch_size: Batch size for bulk copy (0 = all at once) keep_identity: Whether to keep identity values check_constraints: Whether to check constraints keep_nulls: Whether to keep NULL values fire_triggers: Whether to fire triggers Returns: Dictionary with bulk copy result. Example: >>> bulk_copy("abc123", "users", [("John", 25), ("Jane", 30)]) {"status": "completed", "rows_copied": 2}
get_tables Get list of tables from the database. Args: connection_id: The ID returned from connect_tool catalog: Optional catalog filter schema: Optional schema filter Returns: List of table information dictionaries. Example: >>> get_tables("abc123") [{"table_name": "users", "table_type": "TABLE"}, {"table_name": "orders", "table_type": "TABLE"}]
get_columns Get list of columns for a table. Args: connection_id: The ID returned from connect_tool table_name: Name of the table catalog: Optional catalog filter schema: Optional schema filter Returns: List of column information dictionaries. Example: >>> get_columns("abc123", "users") [{"column_name": "id", "data_type": "int", "is_nullable": false}, {"column_name": "name", "data_type": "varchar", "is_nullable": true}]
get_procedures Get list of stored procedures from the database. Args: connection_id: The ID returned from connect_tool catalog: Optional catalog filter schema: Optional schema filter Returns: List of procedure information dictionaries. Example: >>> get_procedures("abc123") [{"procedure_name": "sp_GetUsers", "procedure_schema": "dbo"}]
get_foreign_keys Get foreign keys for a table. Args: connection_id: The ID returned from connect_tool table_name: Name of the table catalog: Optional catalog filter schema: Optional schema filter Returns: List of foreign key information dictionaries. Example: >>> get_foreign_keys("abc123", "orders") [{"foreign_key_name": "FK_orders_users", "column_name": "user_id", "referenced_table": "users", "referenced_column": "id"}]
get_primary_keys Get primary keys for a table. Args: connection_id: The ID returned from connect_tool table_name: Name of the table catalog: Optional catalog filter schema: Optional schema filter Returns: List of primary key information dictionaries. Example: >>> get_primary_keys("abc123", "users") [{"column_name": "id", "key_name": "PK_users"}]
parse_connection_string Parse a SQL Server connection string into components. Args: connection_string: SQL Server connection string Returns: Dictionary of connection string components. Example: >>> parse_connection_string("SERVER=localhost;DATABASE=TestDB;UID=sa;") {"SERVER": "localhost", "DATABASE": "TestDB", "UID": "sa"}
build_connection_string Build a SQL Server connection string from components. Args: server: Server hostname or IP address database: Database name user: Username for SQL authentication password: Password for SQL authentication driver: ODBC driver name (default: ODBC Driver 18 for SQL Server) encrypt: Enable encryption (yes/no) trust_cert: Trust server certificate (yes/no) authentication: Authentication method Returns: Connection string. Example: >>> build_connection_string(server="localhost", database="TestDB") "SERVER=localhost;DATABASE=TestDB;DRIVER={ODBC Driver 18 for SQL Server};"
set_connection_timeout Set the connection timeout for a connection. Args: connection_id: The ID returned from connect_tool timeout: Timeout in seconds Returns: Dictionary with status confirmation. Example: >>> set_connection_timeout("abc123", 30) {"status": "set", "timeout": 30}
set_login_timeout Set the login timeout for a connection. Args: connection_id: The ID returned from connect_tool timeout: Timeout in seconds Returns: Dictionary with status confirmation. Example: >>> set_login_timeout("abc123", 15) {"status": "set", "timeout": 15}
get_connection_info Get information about a connection. Args: connection_id: The ID returned from connect_tool Returns: Dictionary with connection information. Example: >>> get_connection_info("abc123") {"server_name": "localhost", "database": "TestDB", "driver_name": "ODBC Driver 18"}
Permissions 0
No permissions indexed yet.