34 lines
1.7 KiB
Bash
Executable file
34 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Testaufrufe an den DB-Dienst (lokal, Bifröst-Datenbank).
|
|
# scripts/dbcall.sh check
|
|
# scripts/dbcall.sh tables
|
|
# scripts/dbcall.sh describe public.workspaces
|
|
# scripts/dbcall.sh query "SELECT 1"
|
|
# scripts/dbcall.sh tools
|
|
# Überschreibbar: URL, KEY, DBHOST, DBPORT, DBNAME, DBUSER, DBPASS, SSLMODE
|
|
set -euo pipefail
|
|
|
|
URL=${URL:-http://127.0.0.1:8791/mcp}
|
|
KEY=${KEY:-dev-schluessel-12345678}
|
|
|
|
case "${1:-}" in
|
|
check) body=$(python3 -c 'import json; print(json.dumps({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"check_connection","arguments":{}}}))') ;;
|
|
tables) body=$(python3 -c 'import json; print(json.dumps({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_tables","arguments":{}}}))') ;;
|
|
describe) body=$(python3 -c 'import json,sys; print(json.dumps({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"describe_table","arguments":{"table":sys.argv[1]}}}))' "$2") ;;
|
|
query) body=$(python3 -c 'import json,sys; print(json.dumps({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"query","arguments":{"sql":sys.argv[1]}}}))' "$2") ;;
|
|
tools) body='{"jsonrpc":"2.0","id":1,"method":"tools/list"}' ;;
|
|
*) sed -n '2,9p' "$0"; exit 1 ;;
|
|
esac
|
|
|
|
curl -s -X POST "$URL" \
|
|
-H "Authorization: Bearer $KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json, text/event-stream" \
|
|
-H "MCP-Protocol-Version: 2025-06-18" \
|
|
-H "X-DB-Host: ${DBHOST:-127.0.0.1}" \
|
|
-H "X-DB-Port: ${DBPORT:-55433}" \
|
|
-H "X-DB-Database: ${DBNAME:-aiw}" \
|
|
-H "X-DB-User: ${DBUSER:-aiw}" \
|
|
-H "X-DB-Password: ${DBPASS:-aiw}" \
|
|
-H "X-DB-SSLMode: ${SSLMODE:-disable}" \
|
|
-d "$body" | python3 -m json.tool --no-ensure-ascii
|