|
4 | 4 | import subprocess |
5 | 5 | import sys |
6 | 6 |
|
| 7 | +import pytest |
7 | 8 | from cratedb_toolkit.util import DatabaseAdapter |
8 | 9 |
|
9 | 10 |
|
@@ -116,3 +117,41 @@ def test_dbhub(): |
116 | 117 | assert b"Getting prompt: explain_db" in p.stdout |
117 | 118 | assert b"Table: mcp_dbhub in schema 'testdrive'" in p.stdout |
118 | 119 | assert b"Structure:\\n- id (integer)\\n- data (text)" in p.stdout |
| 120 | + |
| 121 | + |
| 122 | +@pytest.mark.skipif(sys.version_info < (3, 12), reason="requires Python 3.12+") |
| 123 | +def test_mcp_alchemy(): |
| 124 | + """ |
| 125 | + Validate the MCP Alchemy server works well. |
| 126 | +
|
| 127 | + MCP Alchemy connects Claude Desktop directly to your databases. |
| 128 | + MCP Alchemy is a MCP (model context protocol) server that gives the LLM access |
| 129 | + to and knowledge about relational databases like SQLite, Postgresql, MySQL & |
| 130 | + MariaDB, Oracle, MS-SQL, and CrateDB. |
| 131 | +
|
| 132 | + It is written in Python and uses SQLAlchemy. |
| 133 | + https://github.com/runekaagaard/mcp-alchemy |
| 134 | + """ |
| 135 | + p = run(f"{sys.executable} example_mcp_alchemy.py") |
| 136 | + assert p.returncode == 0 |
| 137 | + |
| 138 | + # Validate output specific to the MCP server. |
| 139 | + assert b"Processing request of type" in p.stderr |
| 140 | + assert b"ListPromptsRequest" in p.stderr |
| 141 | + assert b"ListResourcesRequest" in p.stderr |
| 142 | + assert b"ListToolsRequest" in p.stderr |
| 143 | + assert b"CallToolRequest" in p.stderr |
| 144 | + |
| 145 | + # Validate output specific to CrateDB. |
| 146 | + assert b"Calling tool: execute_query" in p.stdout |
| 147 | + assert b"mountain: Mont Blanc" in p.stdout |
| 148 | + |
| 149 | + assert b"Calling tool: all_table_names" in p.stdout |
| 150 | + assert b"mcp_alchemy" in p.stdout |
| 151 | + |
| 152 | + assert b"Calling tool: filter_table_names" in p.stdout |
| 153 | + assert b"mcp_alchemy" in p.stdout |
| 154 | + |
| 155 | + assert b"Calling tool: schema_definitions" in p.stdout |
| 156 | + assert b"id: INTEGER, nullable" in p.stdout |
| 157 | + assert b"data: VARCHAR, nullable" in p.stdout |
0 commit comments