Bases: SystemPluginFactory
Factory for permissions plugin.
Source code in ccproxy/plugins/permissions/plugin.py
| def __init__(self) -> None:
"""Initialize factory with manifest."""
# Create manifest with static declarations
manifest = PluginManifest(
name="permissions",
version="0.1.0",
description="Permissions plugin providing authorization services for tool calls",
is_provider=False,
config_class=PermissionsConfig,
)
# Initialize with manifest
super().__init__(manifest)
|
create_runtime
Create runtime instance.
Source code in ccproxy/plugins/permissions/plugin.py
| def create_runtime(self) -> PermissionsRuntime:
"""Create runtime instance."""
return PermissionsRuntime(self.manifest)
|
create_context
create_context(core_services)
Create context and update manifest with routes if enabled.
Source code in ccproxy/plugins/permissions/plugin.py
| def create_context(self, core_services: Any) -> PluginContext:
"""Create context and update manifest with routes if enabled."""
# Get base context
context = super().create_context(core_services)
# Check if plugin is enabled
config = context.get("config")
if isinstance(config, PermissionsConfig) and config.enabled:
# Add routes to manifest
# This is safe because it happens during app creation phase
if not self.manifest.routes:
self.manifest.routes = []
# Always add MCP routes at /mcp root (they're essential for Claude Code)
mcp_route_spec = RouteSpec(
router=mcp_router,
prefix="/mcp",
tags=["mcp"],
)
self.manifest.routes.append(mcp_route_spec)
# Add SSE streaming routes at /permissions if enabled
if config.enable_sse_stream:
permissions_route_spec = RouteSpec(
router=router,
prefix="/permissions",
tags=["permissions"],
)
self.manifest.routes.append(permissions_route_spec)
logger.debug(
"permissions_routes_added_to_manifest",
sse_enabled=config.enable_sse_stream,
)
return context
|