fix: mcp server lint errors

This commit is contained in:
Boris Arzentar 2025-01-23 20:03:31 +01:00
parent d50af60b59
commit d1ce7e531c
3 changed files with 11 additions and 6 deletions

View file

@ -1,5 +1,6 @@
from .server import mcp
def main():
"""Main entry point for the package."""
mcp.run(transport="stdio")

View file

@ -4,9 +4,9 @@ from mcp.client.stdio import stdio_client
# Create server parameters for stdio connection
server_params = StdioServerParameters(
command="mcp", # Executable
args=["run", "src/server.py"], # Optional command line arguments
env=None # Optional environment variables
command="mcp", # Executable
args=["run", "src/server.py"], # Optional command line arguments
env=None, # Optional environment variables
)
text = """
@ -27,6 +27,7 @@ brain, that can learn from available data and make increasingly
more accurate classifications or predictions over time.
"""
async def run():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write, timedelta(minutes=3)) as session:
@ -37,6 +38,8 @@ async def run():
print(f"Cognify result: {toolResult}")
if __name__ == "__main__":
import asyncio
asyncio.run(run())

View file

@ -1,6 +1,7 @@
import os
import cognee
import importlib.util
# from PIL import Image as PILImage
from mcp.server.fastmcp import FastMCP
from cognee.api.v1.search import SearchType
@ -8,6 +9,7 @@ from cognee.shared.data_models import KnowledgeGraph
mcp = FastMCP("cognee", timeout=120000)
@mcp.tool()
async def cognify(text: str, graph_model_file: str = None, graph_model_name: str = None) -> str:
"""Build knowledge graph from the input text"""
@ -19,9 +21,9 @@ async def cognify(text: str, graph_model_file: str = None, graph_model_name: str
await cognee.add(text)
try:
await cognee.cognify(graph_model=graph_model)
await cognee.cognify(graph_model=graph_model)
except Exception as e:
raise ValueError(f"Failed to cognify: {str(e)}")
raise ValueError(f"Failed to cognify: {str(e)}")
return "Ingested"
@ -57,7 +59,6 @@ async def prune() -> str:
# raise ValueError(f"Failed to create visualization: {str(e)}")
def node_to_string(node):
node_data = ", ".join(
[f'{key}: "{value}"' for key, value in node.items() if key in ["id", "name"]]