|
1 | | -import os |
2 | 1 | import logging |
3 | | -import json |
4 | | -from typing import Any, Dict, List, Optional, Literal |
5 | | -from contextlib import asynccontextmanager |
| 2 | +from typing import Any, Dict, List, Literal |
6 | 3 |
|
7 | | -import neo4j |
8 | 4 | from neo4j import AsyncGraphDatabase |
9 | 5 | from pydantic import BaseModel, Field |
10 | 6 |
|
11 | | -from fastmcp.resources.types import TextResource |
12 | 7 | from fastmcp.server import FastMCP |
13 | 8 |
|
14 | 9 | # Set up logging |
@@ -185,9 +180,9 @@ async def search_nodes(self, query: str) -> KnowledgeGraph: |
185 | 180 | # Fallback to simple text search |
186 | 181 | result = await session.run(""" |
187 | 182 | MATCH (e:Entity) |
188 | | - WHERE e.name CONTAINS $query OR e.type CONTAINS $query OR ANY(obs IN e.observations WHERE obs CONTAINS $query) |
| 183 | + WHERE e.name CONTAINS $q OR e.type CONTAINS $q OR ANY(obs IN e.observations WHERE obs CONTAINS $q) |
189 | 184 | RETURN e.name as name, e.type as type, e.observations as observations |
190 | | - """, query=query) |
| 185 | + """, q=query) |
191 | 186 | logger.debug("Using fallback text search") |
192 | 187 |
|
193 | 188 | entities = [] |
@@ -385,14 +380,15 @@ async def main( |
385 | 380 |
|
386 | 381 | # Run the server with the specified transport |
387 | 382 | logger.info(f"Starting server with transport: {transport}") |
388 | | - if transport == "http": |
389 | | - logger.info(f"HTTP server starting on {host}:{port}{path}") |
390 | | - await mcp.run_http_async(host=host, port=port, path=path) |
391 | | - elif transport == "stdio": |
392 | | - logger.info("STDIO server starting") |
393 | | - await mcp.run_stdio_async() |
394 | | - elif transport == "sse": |
395 | | - logger.info(f"SSE server starting on {host}:{port}{path}") |
396 | | - await mcp.run_sse_async(host=host, port=port, path=path) |
397 | | - else: |
398 | | - raise ValueError(f"Unsupported transport: {transport}") |
| 383 | + match transport: |
| 384 | + case "http": |
| 385 | + logger.info(f"HTTP server starting on {host}:{port}{path}") |
| 386 | + await mcp.run_http_async(host=host, port=port, path=path) |
| 387 | + case "stdio": |
| 388 | + logger.info("STDIO server starting") |
| 389 | + await mcp.run_stdio_async() |
| 390 | + case "sse": |
| 391 | + logger.info(f"SSE server starting on {host}:{port}{path}") |
| 392 | + await mcp.run_sse_async(host=host, port=port, path=path) |
| 393 | + case _: |
| 394 | + raise ValueError(f"Unsupported transport: {transport}") |
0 commit comments