config.py•3.62 kB
"""Configuration for PrestaShop MCP server."""
import os
from pathlib import Path
# Database path - where the SQLite database will be stored
DB_PATH = Path.home() / ".mcp" / "prestashop-docs" / "database.db"
# Allow override via environment variable
if env_db_path := os.getenv("PRESTASHOP_DB_PATH"):
DB_PATH = Path(env_db_path)
# Ensure database directory exists
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
# Documentation source path - EXTERNAL folder with PrestaShop official docs
# This should point to a clone of https://github.com/PrestaShop/docs
# Try to find prestashop-docs in various locations
PACKAGE_DIR = Path(__file__).parent
PROJECT_ROOT = PACKAGE_DIR.parent
# Priority 1: Environment variable
if env_docs_path := os.getenv("PRESTASHOP_DOCS_PATH"):
DOCS_PATH = Path(env_docs_path)
# Priority 2: Sibling to project root (shopify-mcp-doc/prestashop-docs)
elif (PROJECT_ROOT.parent / "prestashop-docs").exists():
DOCS_PATH = PROJECT_ROOT.parent / "prestashop-docs"
# Priority 3: Inside project (for Docker builds or local testing)
elif (PROJECT_ROOT / "prestashop-docs").exists():
DOCS_PATH = PROJECT_ROOT / "prestashop-docs"
else:
# Set to expected location even if it doesn't exist
DOCS_PATH = PROJECT_ROOT.parent / "prestashop-docs"
# Validation - warn if docs not found
if not DOCS_PATH.exists():
import warnings
warnings.warn(
f"PrestaShop documentation not found at {DOCS_PATH}. "
f"Please clone: git clone https://github.com/PrestaShop/docs.git {DOCS_PATH}",
UserWarning
)
# Documentation categories (top-level folders in prestashop-docs)
CATEGORIES = {
"admin-api": "admin-api",
"basics": "basics",
"contribute": "contribute",
"development": "development",
"faq": "faq",
"modules": "modules",
"project": "project",
"scale": "scale",
"schemas": "schemas",
"testing": "testing",
"themes": "themes",
"webservice": "webservice",
}
# Document types for classification
DOC_TYPES = {
"hook": "hook", # Structured hook documentation
"reference": "reference", # Command/query references with includes
"tutorial": "tutorial", # How-to guides and tutorials
"guide": "guide", # Installation, deployment, configuration guides
"faq": "faq", # Frequently asked questions
"api": "api", # API documentation (webservice, admin-api)
"component": "component", # Component reference (forms, grids, etc.)
"general": "general", # General documentation
}
# Hook-specific configuration (backward compatibility)
HOOK_TYPES = ["display", "action", "unknown"]
HOOK_ORIGINS = ["core", "module", "theme", "unknown"]
HOOK_LOCATIONS = ["back office", "front office"]
# Paths to specific documentation types within categories
SPECIAL_PATHS = {
"hooks": "modules/concepts/hooks/list-of-hooks",
"domain_references": "development/architecture/domain/references",
"form_types": "development/components/form/types-reference",
"grid_columns": "development/components/grid/columns-reference",
"grid_actions": "development/components/grid/actions-reference",
}
# Indexing configuration
INDEXING_CONFIG = {
"skip_patterns": [
"**/img/**", # Skip image directories
"**/_partials/**", # Partials are included by other files
"**/.github/**", # Skip GitHub workflows
"**/node_modules/**", # Skip dependencies
],
"max_file_size": 5 * 1024 * 1024, # 5 MB max per file
"batch_size": 100, # Process files in batches
}