talkops-kargo-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.
- kargo_mcp_server/__init__.py +3 -0
- kargo_mcp_server/config.py +290 -0
- kargo_mcp_server/exceptions/__init__.py +27 -0
- kargo_mcp_server/exceptions/custom.py +76 -0
- kargo_mcp_server/main.py +40 -0
- kargo_mcp_server/models/__init__.py +113 -0
- kargo_mcp_server/models/common.py +19 -0
- kargo_mcp_server/models/credentials.py +18 -0
- kargo_mcp_server/models/freight.py +204 -0
- kargo_mcp_server/models/project.py +112 -0
- kargo_mcp_server/models/promotion.py +91 -0
- kargo_mcp_server/models/promotion_task.py +26 -0
- kargo_mcp_server/models/schemas.py +267 -0
- kargo_mcp_server/models/stage.py +230 -0
- kargo_mcp_server/models/warehouse.py +93 -0
- kargo_mcp_server/resources/__init__.py +29 -0
- kargo_mcp_server/resources/base.py +22 -0
- kargo_mcp_server/resources/credentials_resources.py +74 -0
- kargo_mcp_server/resources/freight_resources.py +46 -0
- kargo_mcp_server/resources/project_resources.py +168 -0
- kargo_mcp_server/resources/promotion_resources.py +75 -0
- kargo_mcp_server/resources/promotion_task_resources.py +47 -0
- kargo_mcp_server/resources/registry.py +19 -0
- kargo_mcp_server/resources/stage_resources.py +75 -0
- kargo_mcp_server/resources/verification_resources.py +111 -0
- kargo_mcp_server/resources/warehouse_resources.py +51 -0
- kargo_mcp_server/server/__init__.py +9 -0
- kargo_mcp_server/server/bootstrap.py +51 -0
- kargo_mcp_server/server/core.py +32 -0
- kargo_mcp_server/server/middleware.py +135 -0
- kargo_mcp_server/services/__init__.py +7 -0
- kargo_mcp_server/services/kargo_service.py +1947 -0
- kargo_mcp_server/static/KARGO_MCP_INSTRUCTIONS.md +23 -0
- kargo_mcp_server/static/__init__.py +1 -0
- kargo_mcp_server/tools/__init__.py +25 -0
- kargo_mcp_server/tools/base.py +201 -0
- kargo_mcp_server/tools/credentials/__init__.py +1 -0
- kargo_mcp_server/tools/credentials/credentials_tools.py +145 -0
- kargo_mcp_server/tools/diagnostics/__init__.py +1 -0
- kargo_mcp_server/tools/diagnostics/diagnostics_tools.py +136 -0
- kargo_mcp_server/tools/pipeline/__init__.py +5 -0
- kargo_mcp_server/tools/pipeline/pipeline_tools.py +701 -0
- kargo_mcp_server/tools/promotion/promotion_tools.py +801 -0
- kargo_mcp_server/tools/rbac/__init__.py +5 -0
- kargo_mcp_server/tools/rbac/rbac_tools.py +148 -0
- kargo_mcp_server/tools/registry.py +37 -0
- kargo_mcp_server/tools/verification/__init__.py +5 -0
- kargo_mcp_server/tools/verification/verification_tools.py +243 -0
- kargo_mcp_server/utils/__init__.py +49 -0
- kargo_mcp_server/utils/kargo_helpers.py +378 -0
- kargo_mcp_server/utils/redaction.py +141 -0
- kargo_mcp_server/utils/warehouse_spec_builder.py +347 -0
- talkops_kargo_mcp_server-0.2.0.dist-info/METADATA +173 -0
- talkops_kargo_mcp_server-0.2.0.dist-info/RECORD +56 -0
- talkops_kargo_mcp_server-0.2.0.dist-info/WHEEL +4 -0
- talkops_kargo_mcp_server-0.2.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"""Application configuration management for Kargo MCP Server.
|
|
2
|
+
|
|
3
|
+
Provides configuration for the Kargo MCP server, including
|
|
4
|
+
Kargo API settings, write-access gates, toolset filtering, and CLI/env parsing.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from typing import List, Optional, Sequence
|
|
12
|
+
|
|
13
|
+
VALID_TOOLSETS = frozenset({
|
|
14
|
+
"all",
|
|
15
|
+
"readonly",
|
|
16
|
+
"pipeline",
|
|
17
|
+
"promotion",
|
|
18
|
+
"verification",
|
|
19
|
+
"credentials",
|
|
20
|
+
"rbac",
|
|
21
|
+
"diagnostics",
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AuthMode(str, Enum):
|
|
26
|
+
"""Kargo API authentication mode."""
|
|
27
|
+
|
|
28
|
+
ADMIN = "admin" # Server logs in as Kargo admin, obtains JWT
|
|
29
|
+
STATIC = "static" # Server uses a pre-configured bearer token
|
|
30
|
+
PASSTHROUGH = "passthrough" # Forward caller token from MCP client
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _parse_bool_env(value: Optional[str], default: bool = False) -> bool:
|
|
34
|
+
if value is None:
|
|
35
|
+
return default
|
|
36
|
+
return value.strip().lower() in ("1", "true", "yes", "on")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _parse_toolsets(raw: Optional[str]) -> List[str]:
|
|
40
|
+
if not raw:
|
|
41
|
+
return ["all"]
|
|
42
|
+
items = [item.strip().lower() for item in raw.split(",") if item.strip()]
|
|
43
|
+
if not items:
|
|
44
|
+
return ["all"]
|
|
45
|
+
invalid = [t for t in items if t not in VALID_TOOLSETS]
|
|
46
|
+
if invalid:
|
|
47
|
+
raise ValueError(
|
|
48
|
+
f"Unknown toolset(s): {', '.join(invalid)}. "
|
|
49
|
+
f"Valid toolsets are: {', '.join(sorted(VALID_TOOLSETS))}"
|
|
50
|
+
)
|
|
51
|
+
return items
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class KargoConfig:
|
|
56
|
+
"""Kargo API connection configuration."""
|
|
57
|
+
|
|
58
|
+
base_url: str = "http://localhost:8080"
|
|
59
|
+
verify_ssl: bool = True
|
|
60
|
+
auth_mode: AuthMode = AuthMode.ADMIN
|
|
61
|
+
admin_password: Optional[str] = None
|
|
62
|
+
static_bearer_token: Optional[str] = None
|
|
63
|
+
timeout: int = 30
|
|
64
|
+
# Server-managed credential sources (never passed through LLM conversation)
|
|
65
|
+
repo_username: Optional[str] = None
|
|
66
|
+
repo_password: Optional[str] = None
|
|
67
|
+
credentials_file: Optional[str] = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class ServerConfig:
|
|
72
|
+
"""Main MCP server configuration."""
|
|
73
|
+
|
|
74
|
+
# Server identity
|
|
75
|
+
name: str = "kargo-mcp-server"
|
|
76
|
+
version: str = "0.2.0"
|
|
77
|
+
description: str = "Kargo Continuous Promotion MCP Execution Server"
|
|
78
|
+
|
|
79
|
+
# Transport settings (supports stdio and http / streamable-http)
|
|
80
|
+
transport: str = "stdio"
|
|
81
|
+
host: str = "0.0.0.0"
|
|
82
|
+
port: int = 8766
|
|
83
|
+
path: str = "/mcp"
|
|
84
|
+
|
|
85
|
+
# Security & toolset gates (read-only by default)
|
|
86
|
+
allow_write: bool = False
|
|
87
|
+
toolsets: List[str] = field(default_factory=lambda: ["all"])
|
|
88
|
+
|
|
89
|
+
# Server behavior
|
|
90
|
+
debug: bool = False
|
|
91
|
+
default_project: Optional[str] = None
|
|
92
|
+
|
|
93
|
+
# Kargo API configuration
|
|
94
|
+
kargo: KargoConfig = field(default_factory=KargoConfig)
|
|
95
|
+
|
|
96
|
+
def __post_init__(self) -> None:
|
|
97
|
+
if self.kargo is None:
|
|
98
|
+
self.kargo = KargoConfig()
|
|
99
|
+
if isinstance(self.toolsets, str):
|
|
100
|
+
self.toolsets = _parse_toolsets(self.toolsets)
|
|
101
|
+
else:
|
|
102
|
+
normalized = [t.strip().lower() for t in self.toolsets if t and t.strip()]
|
|
103
|
+
if not normalized:
|
|
104
|
+
normalized = ["all"]
|
|
105
|
+
invalid = [t for t in normalized if t not in VALID_TOOLSETS]
|
|
106
|
+
if invalid:
|
|
107
|
+
raise ValueError(
|
|
108
|
+
f"Unknown toolset(s): {', '.join(invalid)}. "
|
|
109
|
+
f"Valid toolsets are: {', '.join(sorted(VALID_TOOLSETS))}"
|
|
110
|
+
)
|
|
111
|
+
self.toolsets = normalized
|
|
112
|
+
if self.transport == "streamable-http":
|
|
113
|
+
self.transport = "http"
|
|
114
|
+
if "readonly" in self.toolsets:
|
|
115
|
+
self.allow_write = False
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Config:
|
|
119
|
+
"""Configuration loader and CLI argument parser."""
|
|
120
|
+
|
|
121
|
+
@staticmethod
|
|
122
|
+
def from_env() -> ServerConfig:
|
|
123
|
+
"""Load configuration from environment variables."""
|
|
124
|
+
auth_mode_str = os.getenv("KARGO_AUTH_MODE", "admin").strip().lower()
|
|
125
|
+
static_token = os.getenv("KARGO_STATIC_BEARER_TOKEN") or os.getenv("KARGO_AUTH_TOKEN") or None
|
|
126
|
+
if auth_mode_str == "bearer":
|
|
127
|
+
auth_mode = AuthMode.STATIC if static_token else AuthMode.ADMIN
|
|
128
|
+
else:
|
|
129
|
+
try:
|
|
130
|
+
auth_mode = AuthMode(auth_mode_str)
|
|
131
|
+
except ValueError:
|
|
132
|
+
auth_mode = AuthMode.ADMIN
|
|
133
|
+
|
|
134
|
+
allow_write = _parse_bool_env(os.getenv("MCP_ALLOW_WRITE"), default=False)
|
|
135
|
+
if _parse_bool_env(os.getenv("MCP_READ_ONLY"), default=False):
|
|
136
|
+
allow_write = False
|
|
137
|
+
|
|
138
|
+
toolsets = _parse_toolsets(os.getenv("MCP_TOOLSETS", "all"))
|
|
139
|
+
if "readonly" in toolsets:
|
|
140
|
+
allow_write = False
|
|
141
|
+
|
|
142
|
+
raw_transport = os.getenv("MCP_TRANSPORT", "stdio").strip().lower()
|
|
143
|
+
if raw_transport == "streamable-http":
|
|
144
|
+
raw_transport = "http"
|
|
145
|
+
|
|
146
|
+
base_url = (
|
|
147
|
+
os.getenv("KARGO_BASE_URL")
|
|
148
|
+
or os.getenv("KARGO_API_URL")
|
|
149
|
+
or "http://localhost:8080"
|
|
150
|
+
)
|
|
151
|
+
default_project = (
|
|
152
|
+
os.getenv("KARGO_PROJECT")
|
|
153
|
+
or os.getenv("KARGO_DEFAULT_PROJECT")
|
|
154
|
+
or os.getenv("MCP_PROJECT")
|
|
155
|
+
or None
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
return ServerConfig(
|
|
159
|
+
name=os.getenv("MCP_SERVER_NAME", "kargo-mcp-server"),
|
|
160
|
+
version=os.getenv("MCP_SERVER_VERSION", "0.2.0"),
|
|
161
|
+
transport=raw_transport,
|
|
162
|
+
host=os.getenv("MCP_HOST", "0.0.0.0"),
|
|
163
|
+
port=int(os.getenv("MCP_PORT", "8766")),
|
|
164
|
+
path=os.getenv("MCP_PATH", "/mcp"),
|
|
165
|
+
allow_write=allow_write,
|
|
166
|
+
toolsets=toolsets,
|
|
167
|
+
debug=_parse_bool_env(os.getenv("MCP_DEBUG"), default=False),
|
|
168
|
+
default_project=default_project,
|
|
169
|
+
kargo=KargoConfig(
|
|
170
|
+
base_url=base_url,
|
|
171
|
+
verify_ssl=_parse_bool_env(os.getenv("KARGO_VERIFY_SSL"), default=True),
|
|
172
|
+
auth_mode=auth_mode,
|
|
173
|
+
admin_password=os.getenv("KARGO_ADMIN_PASSWORD"),
|
|
174
|
+
static_bearer_token=static_token,
|
|
175
|
+
timeout=int(os.getenv("KARGO_TIMEOUT", "30")),
|
|
176
|
+
repo_username=os.getenv("KARGO_REPO_USERNAME"),
|
|
177
|
+
repo_password=os.getenv("KARGO_REPO_PASSWORD"),
|
|
178
|
+
credentials_file=os.getenv("KARGO_CREDENTIALS_FILE"),
|
|
179
|
+
),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
@staticmethod
|
|
183
|
+
def build_arg_parser() -> argparse.ArgumentParser:
|
|
184
|
+
"""Create CLI argument parser."""
|
|
185
|
+
parser = argparse.ArgumentParser(
|
|
186
|
+
prog="kargo-mcp-server",
|
|
187
|
+
description="Kargo Continuous Promotion MCP Execution Server",
|
|
188
|
+
)
|
|
189
|
+
parser.add_argument(
|
|
190
|
+
"--transport",
|
|
191
|
+
choices=["stdio", "http", "streamable-http"],
|
|
192
|
+
default=None,
|
|
193
|
+
help="MCP transport mode (default: env MCP_TRANSPORT or stdio)",
|
|
194
|
+
)
|
|
195
|
+
parser.add_argument("--host", default=None, help="HTTP server bind host")
|
|
196
|
+
parser.add_argument("--port", type=int, default=None, help="HTTP server bind port")
|
|
197
|
+
parser.add_argument("--path", default=None, help="HTTP server endpoint path")
|
|
198
|
+
parser.add_argument(
|
|
199
|
+
"--toolsets",
|
|
200
|
+
default=None,
|
|
201
|
+
help=(
|
|
202
|
+
"Comma-separated toolsets to enable "
|
|
203
|
+
f"({', '.join(sorted(VALID_TOOLSETS))})"
|
|
204
|
+
),
|
|
205
|
+
)
|
|
206
|
+
parser.add_argument(
|
|
207
|
+
"--allow-write",
|
|
208
|
+
action="store_true",
|
|
209
|
+
default=False,
|
|
210
|
+
help="Enable mutating and destructive Kargo tools",
|
|
211
|
+
)
|
|
212
|
+
parser.add_argument(
|
|
213
|
+
"--read-only",
|
|
214
|
+
action="store_true",
|
|
215
|
+
default=False,
|
|
216
|
+
help="Force read-only mode (overrides --allow-write and MCP_ALLOW_WRITE)",
|
|
217
|
+
)
|
|
218
|
+
parser.add_argument(
|
|
219
|
+
"--kargo-url",
|
|
220
|
+
default=None,
|
|
221
|
+
help="Kargo API server base URL (overrides KARGO_BASE_URL)",
|
|
222
|
+
)
|
|
223
|
+
parser.add_argument(
|
|
224
|
+
"--auth-mode",
|
|
225
|
+
choices=["admin", "static", "passthrough"],
|
|
226
|
+
default=None,
|
|
227
|
+
help="Kargo authentication mode (overrides KARGO_AUTH_MODE)",
|
|
228
|
+
)
|
|
229
|
+
parser.add_argument(
|
|
230
|
+
"--project",
|
|
231
|
+
default=None,
|
|
232
|
+
help="Optional default Kargo project name",
|
|
233
|
+
)
|
|
234
|
+
parser.add_argument(
|
|
235
|
+
"--insecure-skip-tls-verify",
|
|
236
|
+
action="store_true",
|
|
237
|
+
default=False,
|
|
238
|
+
help="Disable TLS certificate verification when connecting to Kargo API",
|
|
239
|
+
)
|
|
240
|
+
parser.add_argument(
|
|
241
|
+
"--debug",
|
|
242
|
+
action="store_true",
|
|
243
|
+
default=False,
|
|
244
|
+
help="Enable debug logging",
|
|
245
|
+
)
|
|
246
|
+
return parser
|
|
247
|
+
|
|
248
|
+
@classmethod
|
|
249
|
+
def from_cli_and_env(cls, argv: Optional[Sequence[str]] = None) -> ServerConfig:
|
|
250
|
+
"""Load configuration from environment variables and apply CLI overrides."""
|
|
251
|
+
cfg = cls.from_env()
|
|
252
|
+
if argv is None:
|
|
253
|
+
return cfg
|
|
254
|
+
|
|
255
|
+
parser = cls.build_arg_parser()
|
|
256
|
+
args = parser.parse_args(list(argv))
|
|
257
|
+
|
|
258
|
+
if args.transport is not None:
|
|
259
|
+
cfg.transport = "http" if args.transport == "streamable-http" else args.transport
|
|
260
|
+
if args.host is not None:
|
|
261
|
+
cfg.host = args.host
|
|
262
|
+
if args.port is not None:
|
|
263
|
+
cfg.port = args.port
|
|
264
|
+
if args.path is not None:
|
|
265
|
+
cfg.path = args.path
|
|
266
|
+
if args.toolsets is not None:
|
|
267
|
+
cfg.toolsets = _parse_toolsets(args.toolsets)
|
|
268
|
+
if args.allow_write:
|
|
269
|
+
cfg.allow_write = True
|
|
270
|
+
if args.kargo_url is not None:
|
|
271
|
+
cfg.kargo.base_url = args.kargo_url
|
|
272
|
+
if args.auth_mode is not None:
|
|
273
|
+
cfg.kargo.auth_mode = AuthMode(args.auth_mode)
|
|
274
|
+
if args.project is not None:
|
|
275
|
+
cfg.default_project = args.project
|
|
276
|
+
if args.insecure_skip_tls_verify:
|
|
277
|
+
cfg.kargo.verify_ssl = False
|
|
278
|
+
if args.debug:
|
|
279
|
+
cfg.debug = True
|
|
280
|
+
|
|
281
|
+
# --read-only and 'readonly' toolset always win
|
|
282
|
+
if args.read_only or "readonly" in cfg.toolsets:
|
|
283
|
+
cfg.allow_write = False
|
|
284
|
+
|
|
285
|
+
return cfg
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def load_config(argv: Optional[Sequence[str]] = None) -> ServerConfig:
|
|
289
|
+
"""Convenience loader for ServerConfig."""
|
|
290
|
+
return Config.from_cli_and_env(argv)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Custom exceptions for Kargo MCP server."""
|
|
2
|
+
|
|
3
|
+
from kargo_mcp_server.exceptions.custom import (
|
|
4
|
+
ApiError,
|
|
5
|
+
KargoApiError,
|
|
6
|
+
KargoConflictError,
|
|
7
|
+
KargoOperationError,
|
|
8
|
+
KargoPermissionError,
|
|
9
|
+
KargoPromotionError,
|
|
10
|
+
KargoResourceError,
|
|
11
|
+
KargoResourceNotFoundError,
|
|
12
|
+
KargoValidationError,
|
|
13
|
+
KargoVerificationError,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"ApiError",
|
|
18
|
+
"KargoApiError",
|
|
19
|
+
"KargoConflictError",
|
|
20
|
+
"KargoOperationError",
|
|
21
|
+
"KargoPermissionError",
|
|
22
|
+
"KargoPromotionError",
|
|
23
|
+
"KargoResourceError",
|
|
24
|
+
"KargoResourceNotFoundError",
|
|
25
|
+
"KargoValidationError",
|
|
26
|
+
"KargoVerificationError",
|
|
27
|
+
]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Custom exceptions for Kargo MCP server."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from fastmcp.exceptions import (
|
|
5
|
+
ToolError,
|
|
6
|
+
ResourceError,
|
|
7
|
+
NotFoundError,
|
|
8
|
+
ValidationError,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class KargoApiError(Exception):
|
|
13
|
+
"""Raised for non-2xx responses from the Kargo REST API."""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
status_code: int,
|
|
18
|
+
message: str,
|
|
19
|
+
body: Optional[str] = None,
|
|
20
|
+
) -> None:
|
|
21
|
+
super().__init__(f"Kargo API error {status_code}: {message}")
|
|
22
|
+
self.status_code = status_code
|
|
23
|
+
self.message = message
|
|
24
|
+
self.body = body
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Backward-compatible alias used inside service/tests
|
|
28
|
+
ApiError = KargoApiError
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class KargoOperationError(ToolError):
|
|
32
|
+
"""Error during Kargo tool operations."""
|
|
33
|
+
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class KargoResourceError(ResourceError):
|
|
38
|
+
"""Error during Kargo resource operations."""
|
|
39
|
+
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class KargoResourceNotFoundError(NotFoundError):
|
|
44
|
+
"""Error when a Kargo resource is not found (HTTP 404)."""
|
|
45
|
+
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class KargoValidationError(ValidationError):
|
|
50
|
+
"""Error validating Kargo parameters or CRD specs."""
|
|
51
|
+
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class KargoPermissionError(KargoOperationError):
|
|
56
|
+
"""Error when Kargo RBAC denies an operation (HTTP 401/403)."""
|
|
57
|
+
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class KargoConflictError(KargoOperationError):
|
|
62
|
+
"""Error when a Kargo resource conflicts (HTTP 409)."""
|
|
63
|
+
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class KargoPromotionError(KargoOperationError):
|
|
68
|
+
"""Error when a Kargo promotion or rollback fails."""
|
|
69
|
+
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class KargoVerificationError(KargoOperationError):
|
|
74
|
+
"""Error when a Kargo stage verification fails or cannot be triggered."""
|
|
75
|
+
|
|
76
|
+
pass
|
kargo_mcp_server/main.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Application entry point."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
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 kargo_mcp_server.server.bootstrap import ServerBootstrap
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main(argv: Optional[list[str]] = None) -> None:
|
|
15
|
+
"""Run the Kargo MCP server (supports both stdio and streamable-http)."""
|
|
16
|
+
try:
|
|
17
|
+
mcp, config = ServerBootstrap.initialize(
|
|
18
|
+
argv if argv is not None else sys.argv[1:]
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
if config.transport == "http":
|
|
22
|
+
mcp.run(
|
|
23
|
+
transport="streamable-http",
|
|
24
|
+
host=config.host,
|
|
25
|
+
port=config.port,
|
|
26
|
+
path=config.path,
|
|
27
|
+
)
|
|
28
|
+
else:
|
|
29
|
+
mcp.run()
|
|
30
|
+
except KeyboardInterrupt:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def cli() -> None:
|
|
35
|
+
"""CLI entry point for the kargo-mcp-server command."""
|
|
36
|
+
main()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if __name__ == "__main__":
|
|
40
|
+
cli()
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""Kargo data models package."""
|
|
2
|
+
|
|
3
|
+
from kargo_mcp_server.models.common import ObjectMeta
|
|
4
|
+
from kargo_mcp_server.models.project import (
|
|
5
|
+
Project,
|
|
6
|
+
ProjectConfig,
|
|
7
|
+
ProjectConfigSpec,
|
|
8
|
+
ProjectConfigStatus,
|
|
9
|
+
ProjectStatus,
|
|
10
|
+
ProjectSummary,
|
|
11
|
+
PromotionPolicy,
|
|
12
|
+
StageSelector,
|
|
13
|
+
)
|
|
14
|
+
from kargo_mcp_server.models.stage import (
|
|
15
|
+
AutoPromotionOptions,
|
|
16
|
+
FreightSources,
|
|
17
|
+
RequestedFreight,
|
|
18
|
+
RequestedFreightOrigin,
|
|
19
|
+
Stage,
|
|
20
|
+
StageSpec,
|
|
21
|
+
StageStatus,
|
|
22
|
+
StageSummary,
|
|
23
|
+
)
|
|
24
|
+
from kargo_mcp_server.models.warehouse import (
|
|
25
|
+
FreightCreationCriteria,
|
|
26
|
+
Warehouse,
|
|
27
|
+
WarehouseSpec,
|
|
28
|
+
WarehouseStatus,
|
|
29
|
+
WarehouseSummary,
|
|
30
|
+
)
|
|
31
|
+
from kargo_mcp_server.models.freight import (
|
|
32
|
+
ArtifactReference,
|
|
33
|
+
ChartArtifact,
|
|
34
|
+
Freight,
|
|
35
|
+
FreightOrigin,
|
|
36
|
+
FreightStageState,
|
|
37
|
+
FreightStatus,
|
|
38
|
+
FreightSummary,
|
|
39
|
+
GitCommitArtifact,
|
|
40
|
+
ImageArtifact,
|
|
41
|
+
)
|
|
42
|
+
from kargo_mcp_server.models.promotion import (
|
|
43
|
+
Promotion,
|
|
44
|
+
PromotionSpec,
|
|
45
|
+
PromotionStatus,
|
|
46
|
+
PromotionStepExecutionMetadata,
|
|
47
|
+
PromotionSummary,
|
|
48
|
+
)
|
|
49
|
+
from kargo_mcp_server.models.promotion_task import (
|
|
50
|
+
PromotionTask,
|
|
51
|
+
PromotionTaskSpec,
|
|
52
|
+
)
|
|
53
|
+
from kargo_mcp_server.models.credentials import CreateRepoCredentialsRequest
|
|
54
|
+
from kargo_mcp_server.models.schemas import (
|
|
55
|
+
CredentialOptions,
|
|
56
|
+
ExecutionResult,
|
|
57
|
+
FreightQueryReport,
|
|
58
|
+
FreightTraceReport,
|
|
59
|
+
StageDiagnosisReport,
|
|
60
|
+
StagePromotionTemplateConfig,
|
|
61
|
+
StageVerificationConfig,
|
|
62
|
+
WarehouseDiagnosisReport,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
"ObjectMeta",
|
|
67
|
+
"Project",
|
|
68
|
+
"ProjectConfig",
|
|
69
|
+
"ProjectConfigSpec",
|
|
70
|
+
"ProjectConfigStatus",
|
|
71
|
+
"ProjectStatus",
|
|
72
|
+
"ProjectSummary",
|
|
73
|
+
"PromotionPolicy",
|
|
74
|
+
"StageSelector",
|
|
75
|
+
"AutoPromotionOptions",
|
|
76
|
+
"FreightSources",
|
|
77
|
+
"RequestedFreight",
|
|
78
|
+
"RequestedFreightOrigin",
|
|
79
|
+
"Stage",
|
|
80
|
+
"StageSpec",
|
|
81
|
+
"StageStatus",
|
|
82
|
+
"StageSummary",
|
|
83
|
+
"FreightCreationCriteria",
|
|
84
|
+
"Warehouse",
|
|
85
|
+
"WarehouseSpec",
|
|
86
|
+
"WarehouseStatus",
|
|
87
|
+
"WarehouseSummary",
|
|
88
|
+
"ArtifactReference",
|
|
89
|
+
"ChartArtifact",
|
|
90
|
+
"Freight",
|
|
91
|
+
"FreightOrigin",
|
|
92
|
+
"FreightStageState",
|
|
93
|
+
"FreightStatus",
|
|
94
|
+
"FreightSummary",
|
|
95
|
+
"GitCommitArtifact",
|
|
96
|
+
"ImageArtifact",
|
|
97
|
+
"Promotion",
|
|
98
|
+
"PromotionSpec",
|
|
99
|
+
"PromotionStatus",
|
|
100
|
+
"PromotionStepExecutionMetadata",
|
|
101
|
+
"PromotionSummary",
|
|
102
|
+
"PromotionTask",
|
|
103
|
+
"PromotionTaskSpec",
|
|
104
|
+
"CreateRepoCredentialsRequest",
|
|
105
|
+
"CredentialOptions",
|
|
106
|
+
"ExecutionResult",
|
|
107
|
+
"FreightQueryReport",
|
|
108
|
+
"FreightTraceReport",
|
|
109
|
+
"StageDiagnosisReport",
|
|
110
|
+
"StagePromotionTemplateConfig",
|
|
111
|
+
"StageVerificationConfig",
|
|
112
|
+
"WarehouseDiagnosisReport",
|
|
113
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Common Kargo data models shared across resource types."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ObjectMeta(BaseModel):
|
|
11
|
+
"""Kubernetes-style object metadata."""
|
|
12
|
+
|
|
13
|
+
name: str
|
|
14
|
+
namespace: Optional[str] = None
|
|
15
|
+
labels: Dict[str, str] = Field(default_factory=dict)
|
|
16
|
+
annotations: Dict[str, str] = Field(default_factory=dict)
|
|
17
|
+
creationTimestamp: Optional[datetime] = None
|
|
18
|
+
|
|
19
|
+
model_config = {"populate_by_name": True}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Kargo credentials models."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CreateRepoCredentialsRequest(BaseModel):
|
|
8
|
+
"""Internal request payload for Kargo REST repo-credentials API."""
|
|
9
|
+
|
|
10
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
11
|
+
|
|
12
|
+
name: str
|
|
13
|
+
repoUrl: str
|
|
14
|
+
type: str
|
|
15
|
+
username: Optional[str] = None
|
|
16
|
+
password: Optional[str] = None
|
|
17
|
+
description: Optional[str] = None
|
|
18
|
+
repoUrlIsRegex: Optional[bool] = False
|