mgbam commited on
Commit
1bf6db4
·
verified ·
1 Parent(s): f37945a

Update mcp_server

Browse files
Files changed (1) hide show
  1. mcp_server +8 -6
mcp_server CHANGED
@@ -3,32 +3,34 @@ import sqlite3, json
3
 
4
  mcp = FastMCP("EnterpriseData")
5
 
 
6
  conn = sqlite3.connect(":memory:", check_same_thread=False)
7
  cur = conn.cursor()
8
 
9
  cur.execute("""
10
- CREATE TABLE Customers (
11
  CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
12
  Name TEXT,
13
  Region TEXT,
14
  LastOrderDate TEXT
15
  )
16
  """)
 
17
  cur.executemany(
18
- "INSERT INTO Customers (Name, Region, LastOrderDate) VALUES (?, ?, ?)",
19
  [
20
  ("Acme Corp", "Northeast", "2024-12-01"),
21
- ("Beta Inc", "West", "2025-06-01"),
22
  ("Gamma Co", "Northeast", "2023-09-15"),
23
- ("Delta LLC", "South", "2025-03-20"),
24
- ("Epsilon Ltd", "Northeast", "2025-07-10")
25
  ]
26
  )
27
  conn.commit()
28
 
29
  @mcp.tool()
30
  def query_database(sql: str) -> str:
31
- """Run a SQL query and return JSON."""
32
  try:
33
  cur.execute(sql)
34
  cols = [d[0] for d in cur.description or []]
 
3
 
4
  mcp = FastMCP("EnterpriseData")
5
 
6
+ # In-memory SQLite
7
  conn = sqlite3.connect(":memory:", check_same_thread=False)
8
  cur = conn.cursor()
9
 
10
  cur.execute("""
11
+ CREATE TABLE Customers(
12
  CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
13
  Name TEXT,
14
  Region TEXT,
15
  LastOrderDate TEXT
16
  )
17
  """)
18
+
19
  cur.executemany(
20
+ "INSERT INTO Customers (Name, Region, LastOrderDate) VALUES (?,?,?)",
21
  [
22
  ("Acme Corp", "Northeast", "2024-12-01"),
23
+ ("Beta Inc", "West", "2025-06-01"),
24
  ("Gamma Co", "Northeast", "2023-09-15"),
25
+ ("Delta LLC", "South", "2025-03-20"),
26
+ ("Epsilon Ltd", "Northeast","2025-07-10"),
27
  ]
28
  )
29
  conn.commit()
30
 
31
  @mcp.tool()
32
  def query_database(sql: str) -> str:
33
+ """Run SQL and return JSON rows."""
34
  try:
35
  cur.execute(sql)
36
  cols = [d[0] for d in cur.description or []]