|
3 | 3 |
|
4 | 4 |
|
5 | 5 | import logging |
| 6 | + |
6 | 7 | logging.basicConfig( |
7 | 8 | level=logging.DEBUG, |
8 | 9 | format='%(asctime)s - %(levelname)s - %(message)s', |
9 | 10 | filename='logs/mcp_codeql_python.log', |
10 | 11 | filemode='a' |
11 | 12 | ) |
12 | | -from seclab_taskflow_agent.mcp_servers.codeql.client import run_query, _debug_log |
13 | | -# from seclab_taskflow_agent.path_utils import mcp_data_dir |
14 | | - |
15 | | -from pydantic import Field |
16 | | -#from mcp.server.fastmcp import FastMCP, Context |
17 | | -from fastmcp import FastMCP # use FastMCP 2.0 |
18 | | -from pathlib import Path |
19 | | -import os |
20 | 13 | import csv |
| 14 | +import importlib.resources |
21 | 15 | import json |
| 16 | +import os |
| 17 | +import subprocess |
| 18 | +from pathlib import Path |
| 19 | + |
| 20 | +#from mcp.server.fastmcp import FastMCP, Context |
| 21 | +from fastmcp import FastMCP # use FastMCP 2.0 |
| 22 | + |
| 23 | +# from seclab_taskflow_agent.path_utils import mcp_data_dir |
| 24 | +from pydantic import Field |
| 25 | +from seclab_taskflow_agent.mcp_servers.codeql.client import _debug_log, run_query |
22 | 26 | from sqlalchemy import create_engine |
23 | 27 | from sqlalchemy.orm import Session |
24 | | -import subprocess |
25 | | -import importlib.resources |
26 | 28 |
|
27 | | -from .codeql_sqlite_models import Base, Source |
28 | 29 | from ..utils import process_repo |
| 30 | +from .codeql_sqlite_models import Base, Source |
29 | 31 |
|
30 | 32 | MEMORY = Path(os.getenv('DATA_DIR', default='/app/data')) |
31 | 33 | CODEQL_DBS_BASE_PATH = Path(os.getenv('CODEQL_DBS_BASE_PATH', default='/app/data')) |
@@ -96,13 +98,12 @@ def store_new_source(self, repo, source_location, line, source_type, notes, upda |
96 | 98 | existing.notes = (existing.notes or "") + notes |
97 | 99 | session.commit() |
98 | 100 | return f"Updated notes for source at {source_location}, line {line} in {repo}." |
99 | | - else: |
100 | | - if update: |
101 | | - return f"No source exists at repo {repo}, location {source_location}, line {line} to update." |
102 | | - new_source = Source(repo = repo, source_location = source_location, line = line, source_type = source_type, notes = notes) |
103 | | - session.add(new_source) |
104 | | - session.commit() |
105 | | - return f"Added new source for {source_location} in {repo}." |
| 101 | + if update: |
| 102 | + return f"No source exists at repo {repo}, location {source_location}, line {line} to update." |
| 103 | + new_source = Source(repo = repo, source_location = source_location, line = line, source_type = source_type, notes = notes) |
| 104 | + session.add(new_source) |
| 105 | + session.commit() |
| 106 | + return f"Added new source for {source_location} in {repo}." |
106 | 107 |
|
107 | 108 | def get_sources(self, repo): |
108 | 109 | with Session(self.engine) as session: |
@@ -221,5 +222,5 @@ def clear_codeql_repo(owner: str = Field(description="The owner of the GitHub re |
221 | 222 | if not os.path.isdir('/.codeql/packages/codeql/python-all'): |
222 | 223 | pack_path = importlib.resources.files('seclab_taskflows.mcp_servers.codeql_python.queries').joinpath('mcp-python') |
223 | 224 | print(f"Installing CodeQL pack from {pack_path}") |
224 | | - subprocess.run(["codeql", "pack", "install", pack_path]) |
| 225 | + subprocess.run(["codeql", "pack", "install", pack_path], check=False) |
225 | 226 | mcp.run(show_banner=False, transport="http", host="127.0.0.1", port=9998) |
0 commit comments