Skip to content
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies = [
"parse==1.20.2",
"parso==0.8.4",
"pathable==0.4.4",
"platformdirs==4.5.0",
"pluggy==1.6.0",
"pycparser==2.23",
"pydantic==2.11.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
import re
from urllib.parse import urlparse, unquote
import zipfile
from seclab_taskflow_agent.path_utils import mcp_data_dir

mcp = FastMCP("CodeQL")

CODEQL_DBS_BASE_PATH = Path(os.getenv('CODEQL_DBS_BASE_PATH', default='/workspaces'))
CODEQL_DBS_BASE_PATH = mcp_data_dir('seclab-taskflow-agent', 'codeql', 'CODEQL_DBS_BASE_PATH')

# tool name -> templated query lookup for supported languages
TEMPLATED_QUERY_PATHS = {
Expand Down
4 changes: 2 additions & 2 deletions src/seclab_taskflow_agent/mcp_servers/logbook/logbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
import json
from pathlib import Path
import os
from seclab_taskflow_agent.path_utils import mcp_data_dir

mcp = FastMCP("Logbook")

LOG = {}

LOGBOOK = Path(__file__).parent.resolve() / Path(os.getenv('LOGBOOK_STATE_DIR', default='./')) / Path("logbook.json")

LOGBOOK = mcp_data_dir('seclab-taskflow-agent', 'logbook', 'LOGBOOK_STATE_DIR') / Path("logbook.json")

def ensure_log():
global LOG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any
from .memcache_backend.dictionary_file import MemcacheDictionaryFileBackend
from .memcache_backend.sqlite import SqliteBackend
from seclab_taskflow_agent.path_utils import mcp_data_dir

mcp = FastMCP("Memcache")

Expand All @@ -27,7 +28,7 @@
# if MEMCACHE_STATE_DIR contains an absolute path we WANT the user to be able
# to override the relative path in that case this path join will return
# /MEMCACHE_STATE_DIR/memory.json
MEMORY = Path(__file__).parent.resolve() / Path(os.getenv('MEMCACHE_STATE_DIR', default='./'))
MEMORY = mcp_data_dir('seclab-taskflow-agent', 'memcache', 'MEMCACHE_STATE_DIR')
BACKEND = os.getenv('MEMCACHE_BACKEND', default='sqlite')

backend = backends.get(BACKEND)(str(MEMORY))
Expand Down
27 changes: 27 additions & 0 deletions src/seclab_taskflow_agent/path_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2025 GitHub
# SPDX-License-Identifier: MIT

import platformdirs
import os
from pathlib import Path


def mcp_data_dir(packagename: str, mcpname: str, env_override: str | None):
"""
Create a directory for an MCP to store its data.
env_override is the name of an environment variable that
can be used to override the default location.
"""
if env_override:
p = os.getenv(env_override)
if p:
return Path(p)
# Use [platformdirs](https://pypi.org/project/platformdirs/) to
# choose an appropriate location.
d = platformdirs.user_data_dir(appname = "seclab-taskflow-agent",
appauthor = "GitHubSecurityLab",
ensure_exists = True)
# Each MCP server gets its own sub-directory
p = Path(d).joinpath(packagename).joinpath(mcpname)
p.mkdir(parents = True, exist_ok = True)
return p