talkops-argocd-mcp-server 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. argocd_mcp_server/__init__.py +0 -0
  2. argocd_mcp_server/config.py +104 -0
  3. argocd_mcp_server/exceptions/__init__.py +31 -0
  4. argocd_mcp_server/exceptions/custom.py +79 -0
  5. argocd_mcp_server/main.py +39 -0
  6. argocd_mcp_server/prompts/__init__.py +25 -0
  7. argocd_mcp_server/prompts/base.py +31 -0
  8. argocd_mcp_server/prompts/deployment_workflows.py +529 -0
  9. argocd_mcp_server/prompts/registry.py +37 -0
  10. argocd_mcp_server/prompts/repository_workflows.py +1422 -0
  11. argocd_mcp_server/resources/__init__.py +23 -0
  12. argocd_mcp_server/resources/argocd_resources.py +270 -0
  13. argocd_mcp_server/resources/base.py +31 -0
  14. argocd_mcp_server/resources/registry.py +37 -0
  15. argocd_mcp_server/resources/workflow_resource.py +52 -0
  16. argocd_mcp_server/scripts/fetch_argocd_token.py +171 -0
  17. argocd_mcp_server/server/__init__.py +4 -0
  18. argocd_mcp_server/server/bootstrap.py +45 -0
  19. argocd_mcp_server/server/core.py +48 -0
  20. argocd_mcp_server/server/middleware.py +126 -0
  21. argocd_mcp_server/services/__init__.py +4 -0
  22. argocd_mcp_server/services/argocd_mgmt.py +885 -0
  23. argocd_mcp_server/services/argocd_service.py +794 -0
  24. argocd_mcp_server/static/ARGOCD_MCP_INSTRUCTIONS.md +164 -0
  25. argocd_mcp_server/static/ARGOCD_WORKFLOW.md +224 -0
  26. argocd_mcp_server/tools/__init__.py +28 -0
  27. argocd_mcp_server/tools/application_manager/__init__.py +3 -0
  28. argocd_mcp_server/tools/application_manager/app_management.py +427 -0
  29. argocd_mcp_server/tools/base.py +31 -0
  30. argocd_mcp_server/tools/deployment_executor/__init__.py +3 -0
  31. argocd_mcp_server/tools/deployment_executor/deployment_operations.py +614 -0
  32. argocd_mcp_server/tools/registry.py +37 -0
  33. argocd_mcp_server/tools/repository_mgmt/__init__.py +6 -0
  34. argocd_mcp_server/tools/repository_mgmt/project_operations.py +416 -0
  35. argocd_mcp_server/tools/repository_mgmt/repository_operations.py +717 -0
  36. argocd_mcp_server/utils/__init__.py +0 -0
  37. argocd_mcp_server/utils/argocd_helper.py +51 -0
  38. talkops_argocd_mcp_server-0.2.0.dist-info/METADATA +607 -0
  39. talkops_argocd_mcp_server-0.2.0.dist-info/RECORD +41 -0
  40. talkops_argocd_mcp_server-0.2.0.dist-info/WHEEL +4 -0
  41. talkops_argocd_mcp_server-0.2.0.dist-info/entry_points.txt +2 -0
File without changes
@@ -0,0 +1,104 @@
1
+ """Application configuration management."""
2
+
3
+ import os
4
+ from dataclasses import dataclass, field
5
+ from typing import Optional
6
+
7
+
8
+ @dataclass
9
+ class ArgoCDConfig:
10
+ """ArgoCD configuration."""
11
+ server_url: str = 'https://argocd-server.argocd.svc:443'
12
+ auth_token: Optional[str] = None
13
+ insecure: bool = False
14
+ timeout: int = 300
15
+ # If connection to multiple argocd instances is needed, we might need a mapping here.
16
+ # For now, assuming one ArgoCD server manages multiple clusters.
17
+
18
+
19
+ @dataclass
20
+ class GitRepoConfig:
21
+ """Git repository credentials for onboarding (HTTPS and SSH).
22
+
23
+ Loaded from environment variables so secrets are not hardcoded.
24
+
25
+ HTTPS (onboard_repository_https):
26
+ GIT_USERNAME: Git username (can be empty for token-only auth).
27
+ GIT_PASSWORD: Required for HTTPS; use a GitHub Personal Access Token (PAT).
28
+
29
+ SSH (onboard_repository_ssh):
30
+ SSH_PRIVATE_KEY_PATH: Path to SSH private key file (default: ~/.ssh/id_rsa).
31
+ """
32
+ username: str = ''
33
+ password: Optional[str] = None
34
+ ssh_private_key_path: str = '~/.ssh/id_rsa'
35
+
36
+ @property
37
+ def is_configured(self) -> bool:
38
+ """True if HTTPS auth can be used (password is set)."""
39
+ return bool(self.password)
40
+
41
+
42
+ @dataclass
43
+ class LoggingConfig:
44
+ """Logging configuration."""
45
+ level: str = 'INFO'
46
+ format: str = 'json'
47
+ file_path: str = './logs/mcp_server.log'
48
+ max_bytes: int = 10485760 # 10MB
49
+
50
+
51
+ @dataclass
52
+ class ServerConfig:
53
+ """MCP server configuration."""
54
+ name: str = 'argocd-mcp-server'
55
+ version: str = '0.1.0'
56
+ transport: str = 'http' # http (HTTP/SSE) or stdio
57
+ host: str = '0.0.0.0'
58
+ port: int = 8770 # HTTP/SSE server port
59
+ path: str = '/mcp' # SSE endpoint path
60
+ allow_write: bool = False # Enable write access for mutating operations
61
+ # HTTP server timeout settings (in seconds)
62
+ http_timeout: int = 300 # HTTP request timeout
63
+ http_keepalive_timeout: int = 5 # HTTP keepalive timeout
64
+ http_connect_timeout: int = 60 # HTTP connection timeout
65
+
66
+ argocd: ArgoCDConfig = field(default_factory=ArgoCDConfig)
67
+ git: GitRepoConfig = field(default_factory=GitRepoConfig)
68
+ logging: LoggingConfig = field(default_factory=LoggingConfig)
69
+
70
+
71
+ class Config:
72
+ """Configuration loader."""
73
+
74
+ @staticmethod
75
+ def from_env() -> ServerConfig:
76
+ """Load configuration from environment variables."""
77
+ config = ServerConfig(
78
+ name=os.getenv('MCP_SERVER_NAME', 'argocd-mcp-server'),
79
+ version=os.getenv('MCP_SERVER_VERSION', '0.1.0'),
80
+ transport=os.getenv('MCP_TRANSPORT', 'http'),
81
+ host=os.getenv('MCP_HOST', '0.0.0.0'),
82
+ port=int(os.getenv('MCP_PORT', '8770')),
83
+ path=os.getenv('MCP_PATH', '/mcp'),
84
+ allow_write=os.getenv('MCP_ALLOW_WRITE', 'true').lower() == 'true',
85
+ http_timeout=int(os.getenv('MCP_HTTP_TIMEOUT', '300')),
86
+ http_keepalive_timeout=int(os.getenv('MCP_HTTP_KEEPALIVE_TIMEOUT', '5')),
87
+ http_connect_timeout=int(os.getenv('MCP_HTTP_CONNECT_TIMEOUT', '60')),
88
+ argocd=ArgoCDConfig(
89
+ server_url=os.getenv('ARGOCD_SERVER_URL', 'https://argocd-server.argocd.svc:443'),
90
+ auth_token=os.getenv('ARGOCD_AUTH_TOKEN'),
91
+ insecure=os.getenv('ARGOCD_INSECURE', 'false').lower() == 'true',
92
+ timeout=int(os.getenv('ARGOCD_TIMEOUT', '300')),
93
+ ),
94
+ git=GitRepoConfig(
95
+ username=os.getenv('GIT_USERNAME', ''),
96
+ password=os.getenv('GIT_PASSWORD') or None,
97
+ ssh_private_key_path=os.getenv('SSH_PRIVATE_KEY_PATH', '~/.ssh/id_rsa'),
98
+ ),
99
+ logging=LoggingConfig(
100
+ level=os.getenv('MCP_LOG_LEVEL', 'INFO'),
101
+ format=os.getenv('MCP_LOG_FORMAT', 'json'),
102
+ ),
103
+ )
104
+ return config
@@ -0,0 +1,31 @@
1
+ from .custom import (
2
+ ToolExecutionError,
3
+ ArgoDBNotAvailable,
4
+ ApplicationNotFound,
5
+ SyncOperationFailed,
6
+ ValidationFailed,
7
+ ArgoCDOperationError,
8
+ ArgoCDConnectionError,
9
+ KubernetesOperationError,
10
+ ArgoCDResourceError,
11
+ ArgoCDNotFoundError,
12
+ SyncOperationError,
13
+ RolloutOperationError,
14
+ ArgoCDValidationError,
15
+ )
16
+
17
+ __all__ = [
18
+ "ToolExecutionError",
19
+ "ArgoDBNotAvailable",
20
+ "ApplicationNotFound",
21
+ "SyncOperationFailed",
22
+ "ValidationFailed",
23
+ "ArgoCDOperationError",
24
+ "ArgoCDConnectionError",
25
+ "KubernetesOperationError",
26
+ "ArgoCDResourceError",
27
+ "ArgoCDNotFoundError",
28
+ "SyncOperationError",
29
+ "RolloutOperationError",
30
+ "ArgoCDValidationError",
31
+ ]
@@ -0,0 +1,79 @@
1
+ """Custom exceptions for ArgoCD MCP server.
2
+
3
+ Following FastMCP exceptions from:
4
+ https://gofastmcp.com/python-sdk/fastmcp-exceptions
5
+ """
6
+
7
+ from fastmcp.exceptions import (
8
+ FastMCPError,
9
+ ToolError,
10
+ ResourceError,
11
+ NotFoundError,
12
+ ValidationError,
13
+ )
14
+
15
+
16
+ class ToolExecutionError(ToolError):
17
+ """Base exception for tool execution failures"""
18
+ pass
19
+
20
+
21
+ class ArgoDBNotAvailable(ToolExecutionError):
22
+ """ArgoCD server unavailable"""
23
+ pass
24
+
25
+
26
+ class ApplicationNotFound(NotFoundError):
27
+ """Application doesn't exist"""
28
+ pass
29
+
30
+
31
+ class SyncOperationFailed(ToolExecutionError):
32
+ """Sync operation failed"""
33
+ pass
34
+
35
+
36
+ class ValidationFailed(ValidationError):
37
+ """Pre-deployment validation failed"""
38
+ pass
39
+
40
+
41
+ # Additional exceptions that might be useful based on functionality
42
+ class ArgoCDOperationError(ToolExecutionError):
43
+ """Error during generic ArgoCD operations."""
44
+ pass
45
+
46
+
47
+ class ArgoCDConnectionError(ToolExecutionError):
48
+ """Error connecting to ArgoCD server."""
49
+ pass
50
+
51
+
52
+ class KubernetesOperationError(ToolExecutionError):
53
+ """Error during Kubernetes operations."""
54
+ pass
55
+
56
+
57
+ class ArgoCDResourceError(ResourceError):
58
+ """Error accessing ArgoCD resources."""
59
+ pass
60
+
61
+
62
+ class ArgoCDNotFoundError(NotFoundError):
63
+ """Error when an ArgoCD resource is not found (generic)."""
64
+ pass
65
+
66
+
67
+ class SyncOperationError(ToolExecutionError):
68
+ """Error during application sync operations (alias for SyncOperationFailed if needed or generic sync error)."""
69
+ pass
70
+
71
+
72
+ class RolloutOperationError(ToolExecutionError):
73
+ """Error during rollout operations."""
74
+ pass
75
+
76
+
77
+ class ArgoCDValidationError(ValidationError):
78
+ """Error validating application configuration (generic)."""
79
+ pass
@@ -0,0 +1,39 @@
1
+ """Application entry point."""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ # Add project root to Python path for direct execution with uv run
7
+ project_root = Path(__file__).parent.parent
8
+ if str(project_root) not in sys.path:
9
+ sys.path.insert(0, str(project_root))
10
+
11
+ from argocd_mcp_server.server.bootstrap import ServerBootstrap
12
+
13
+
14
+ def main():
15
+ """Run the MCP server."""
16
+ try:
17
+ mcp, config = ServerBootstrap.initialize()
18
+
19
+ # Run FastMCP server with the configured transport
20
+ if config.transport == 'http':
21
+ # HTTP/Streamable HTTP transport mode (single unified endpoint)
22
+ mcp.run(transport='streamable-http', host=config.host, port=config.port, path=config.path)
23
+ else:
24
+ # STDIO transport mode (default for MCP)
25
+ mcp.run()
26
+
27
+ except KeyboardInterrupt:
28
+ pass
29
+ except Exception as e:
30
+ raise
31
+
32
+
33
+ def cli():
34
+ """CLI entry point for the argocd-mcp-server command."""
35
+ main()
36
+
37
+
38
+ if __name__ == '__main__':
39
+ cli()
@@ -0,0 +1,25 @@
1
+ from .base import BasePrompt
2
+ from .registry import PromptRegistry
3
+ from .deployment_workflows import ArgoCDPrompts
4
+ from .repository_workflows import RepositoryWorkflowPrompts
5
+
6
+ __all__ = ["BasePrompt", "PromptRegistry", "ArgoCDPrompts", "RepositoryWorkflowPrompts", "initialize_prompts"]
7
+
8
+
9
+ def initialize_prompts(service_locator) -> None:
10
+ """Initialize and register all prompts.
11
+
12
+ Args:
13
+ service_locator: Dictionary of services
14
+
15
+ Returns:
16
+ Configured PromptRegistry
17
+ """
18
+ registry = PromptRegistry(service_locator)
19
+
20
+ # Register all prompts
21
+ registry.register_prompt(ArgoCDPrompts(service_locator))
22
+ registry.register_prompt(RepositoryWorkflowPrompts(service_locator))
23
+
24
+ return registry
25
+
@@ -0,0 +1,31 @@
1
+ """Base class for all prompts."""
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import Dict, Any
5
+ from argocd_mcp_server.config import ServerConfig
6
+
7
+
8
+ class BasePrompt(ABC):
9
+ """Abstract base class for all prompts.
10
+
11
+ Subclasses implement specific guided workflow logic while inheriting
12
+ common patterns like dependency injection.
13
+ """
14
+
15
+ def __init__(self, service_locator: Dict[str, Any]):
16
+ """Initialize prompt with service locator.
17
+
18
+ Args:
19
+ service_locator: Dictionary of services (argocd_service, config, etc.)
20
+ """
21
+ self.argocd_service = service_locator.get('argocd_service')
22
+ self.config: ServerConfig = service_locator.get('config')
23
+
24
+ @abstractmethod
25
+ def register(self, mcp_instance) -> None:
26
+ """Register prompt with FastMCP instance.
27
+
28
+ Args:
29
+ mcp_instance: FastMCP server instance
30
+ """
31
+ pass