Skip to content

Commit 043d947

Browse files
rushilpatel0jayhackcodegen-sh[bot]
authored
Rpatel/codegen mcp claude command (#1193)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed --------- Co-authored-by: jayhack <jayhack.0@gmail.com> Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
1 parent 7568c39 commit 043d947

39 files changed

+2437
-402
lines changed

docs/docs.json

Lines changed: 136 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,138 @@
11
{
2-
"$schema": "https://mintlify.com/docs.json",
3-
"theme": "maple",
4-
"name": "Codegen Documentation",
5-
"colors": {
6-
"primary": "#a277ff",
7-
"light": "#a277ff",
8-
"dark": "#a277ff"
9-
},
10-
"favicon": "/favicon.svg",
11-
"navigation": {
12-
"tabs": [
13-
{
14-
"tab": "Documentation",
15-
"groups": [
16-
{
17-
"group": "Overview",
18-
"pages": [
19-
"introduction/overview",
20-
"introduction/api",
21-
"introduction/prompting",
22-
"introduction/community",
23-
"introduction/about",
24-
"introduction/faq"
25-
]
26-
},
27-
{
28-
"group": "Capabilities",
29-
"pages": ["capabilities/capabilities", "capabilities/wake-up", "capabilities/interrupts"]
30-
},
31-
{
32-
"group": "Integrations",
33-
"pages": [
34-
"integrations/github",
35-
"integrations/slack",
36-
"integrations/linear",
37-
"integrations/jira",
38-
"integrations/notion",
39-
"integrations/figma",
40-
"integrations/circleci",
41-
"integrations/web-search",
42-
"integrations/postgres",
43-
"integrations/mcp"
44-
]
45-
},
46-
{
47-
"group": "Sandboxes",
48-
"pages": [
49-
"sandboxes/overview",
50-
"sandboxes/setup-commands",
51-
"sandboxes/image-snapshots",
52-
"sandboxes/environment-variables",
53-
"sandboxes/secrets",
54-
"sandboxes/editor",
55-
"sandboxes/web-preview"
56-
]
57-
},
58-
{
59-
"group": "Settings",
60-
"pages": ["settings/repo-rules", "settings/model-configuration"]
61-
}
62-
]
63-
},
64-
{
65-
"tab": "API Reference",
66-
"groups": [
67-
{
68-
"group": "Endpoints",
69-
"openapi": {
70-
"source": "/api-reference/openapi3.json",
71-
"directory": "api-reference"
72-
}
73-
},
74-
{
75-
"group": "Guides",
76-
"pages": ["api-reference/agent-run-logs", "api-reference/github-actions"]
77-
}
78-
]
79-
}
80-
]
81-
},
82-
"logo": {
83-
"light": "https://cdn.prod.website-files.com/67070304751b9b01bf6a161c/679bcf45bf55446746125835_Codegen_Logomark_Light.svg",
84-
"dark": "https://cdn.prod.website-files.com/67070304751b9b01bf6a161c/679bcf45a3e32761c42b324b_Codegen_Logomark_Dark.svg"
85-
},
86-
"appearance": {
87-
"default": "dark"
88-
},
89-
"background": {
90-
"decoration": "gradient"
91-
},
92-
"navbar": {
93-
"primary": {
94-
"type": "button",
95-
"label": "GitHub",
96-
"href": "https://github.com/codegen-sh/codegen-sdk"
97-
}
98-
},
99-
"seo": {
100-
"metatags": {
101-
"og:site_name": "Codegen Documentation",
102-
"og:title": "Codegen Documentation - 10x Your Engineering",
103-
"og:description": "Complete documentation for Codegen, the AI-powered software engineering agent. Learn how to integrate with GitHub, Slack, Linear, and more.",
104-
"og:url": "https://docs.codegen.com",
105-
"og:locale": "en_US",
106-
"og:logo": "https://i.imgur.com/f4OVOqI.png",
107-
"article:publisher": "Codegen, Inc.",
108-
"twitter:site": "@codegen"
109-
},
110-
"indexing": "navigable"
111-
},
112-
"footer": {
113-
"socials": {
114-
"x": "https://x.com/codegen",
115-
"linkedin": "https://linkedin.com/company/codegen-dot-com"
116-
}
117-
},
118-
"integrations": {
119-
"posthog": {
120-
"apiKey": "phc_GLxaINoQJnuyCyxDmTciQqzdKBYFVDkY7bRBO4bDdso"
121-
}
122-
},
123-
"head": [
124-
{
125-
"tag": "script",
126-
"content": "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-T7G5S78D');"
127-
}
128-
]
2+
"$schema": "https://mintlify.com/docs.json",
3+
"theme": "maple",
4+
"name": "Codegen",
5+
"colors": {
6+
"primary": "#a277ff",
7+
"light": "#a277ff",
8+
"dark": "#a277ff"
9+
},
10+
"favicon": "/favicon.svg",
11+
"navigation": {
12+
"tabs": [
13+
{
14+
"tab": "Documentation",
15+
"groups": [
16+
{
17+
"group": "Overview",
18+
"pages": [
19+
"introduction/overview",
20+
"introduction/api",
21+
"introduction/prompting",
22+
"introduction/community",
23+
"introduction/about",
24+
"introduction/faq"
25+
]
26+
},
27+
{
28+
"group": "Capabilities",
29+
"pages": ["capabilities/capabilities", "capabilities/wake-up"]
30+
},
31+
{
32+
"group": "Integrations",
33+
"pages": [
34+
"integrations/github",
35+
"integrations/slack",
36+
"integrations/linear",
37+
"integrations/notion",
38+
"integrations/figma",
39+
"integrations/circleci",
40+
"integrations/web-search",
41+
"integrations/postgres"
42+
]
43+
},
44+
{
45+
"group": "Sandboxes",
46+
"pages": [
47+
"sandboxes/overview",
48+
"sandboxes/setup-commands",
49+
"sandboxes/environment-variables",
50+
"sandboxes/secrets",
51+
"sandboxes/editor",
52+
"sandboxes/web-preview"
53+
]
54+
},
55+
{
56+
"group": "Settings",
57+
"pages": ["settings/repo-rules", "settings/model-configuration"]
58+
}
59+
]
60+
},
61+
{
62+
"tab": "API Reference",
63+
"groups": [
64+
{
65+
"group": "Endpoints",
66+
"openapi": {
67+
"source": "/api-reference/openapi3.json",
68+
"directory": "api-reference"
69+
}
70+
},
71+
{
72+
"group": "Guides",
73+
"pages": ["api-reference/agent-run-logs"]
74+
}
75+
]
76+
},
77+
{
78+
"tab": "Blog",
79+
"groups": [
80+
{
81+
"group": "Blog",
82+
"pages": ["blog/posts", "blog/devin", "blog/act-via-code"]
83+
}
84+
]
85+
},
86+
{
87+
"tab": "Changelog",
88+
"groups": [
89+
{
90+
"group": "Changelog",
91+
"pages": ["changelog/changelog"]
92+
}
93+
]
94+
}
95+
]
96+
},
97+
"logo": {
98+
"light": "https://cdn.prod.website-files.com/67070304751b9b01bf6a161c/679bcf45bf55446746125835_Codegen_Logomark_Light.svg",
99+
"dark": "https://cdn.prod.website-files.com/67070304751b9b01bf6a161c/679bcf45a3e32761c42b324b_Codegen_Logomark_Dark.svg"
100+
},
101+
"appearance": {
102+
"default": "dark"
103+
},
104+
"background": {
105+
"decoration": "gradient"
106+
},
107+
"navbar": {
108+
"primary": {
109+
"type": "button",
110+
"label": "GitHub",
111+
"href": "https://github.com/codegen-sh/codegen-sdk"
112+
}
113+
},
114+
"seo": {
115+
"metatags": {
116+
"og:site_name": "Codegen",
117+
"og:title": "Codegen - The SWE that Never Sleeps",
118+
"og:description": "Code agents accessible via API, Slack, Linear, Github, and more.",
119+
"og:url": "https://docs.codegen.com",
120+
"og:locale": "en_US",
121+
"og:logo": "https://i.imgur.com/f4OVOqI.png",
122+
"article:publisher": "Codegen, Inc.",
123+
"twitter:site": "@codegen"
124+
},
125+
"indexing": "navigable"
126+
},
127+
"footer": {
128+
"socials": {
129+
"x": "https://x.com/codegen",
130+
"linkedin": "https://linkedin.com/company/codegen-dot-com"
131+
}
132+
},
133+
"integrations": {
134+
"posthog": {
135+
"apiKey": "phc_GLxaINoQJnuyCyxDmTciQqzdKBYFVDkY7bRBO4bDdso"
136+
}
137+
}
129138
}

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codegen/agents/agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from codegen_api_client.models.create_agent_run_input import CreateAgentRunInput
99

1010
from codegen.agents.constants import CODEGEN_BASE_API_URL
11+
from codegen.cli.utils.org import resolve_org_id
1112

1213

1314
class AgentTask:
@@ -53,7 +54,11 @@ def __init__(self, token: str | None, org_id: int | None = None, base_url: str |
5354
org_id: Optional organization ID. If not provided, default org will be used.
5455
"""
5556
self.token = token
56-
self.org_id = org_id or int(os.environ.get("CODEGEN_ORG_ID", "1")) # Default to org ID 1 if not specified
57+
resolved_org = resolve_org_id(org_id)
58+
if resolved_org is None:
59+
# Keep previous behavior only as last resort to avoid exceptions in legacy paths
60+
resolved_org = int(os.environ.get("CODEGEN_ORG_ID", "1"))
61+
self.org_id = resolved_org
5762

5863
# Configure API client
5964
config = Configuration(host=base_url, access_token=token)

src/codegen/agents/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
CODEGEN_BASE_API_URL = "https://codegen-sh--rest-api.modal.run"
1+
import os
2+
3+
from codegen.cli.api.endpoints import API_ENDPOINT
4+
5+
# Prefer explicit override; fall back to the CLI's unified API endpoint
6+
CODEGEN_BASE_API_URL = os.environ.get("CODEGEN_API_BASE_URL", API_ENDPOINT.rstrip("/"))

src/codegen/cli/api/client.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,3 @@ def _make_request(
8787
except requests.RequestException as e:
8888
msg = f"Network error: {e!s}"
8989
raise ServerError(msg)
90-
91-
def identify(self) -> Identity:
92-
"""Get user identity information."""
93-
# TODO: Implement actual API call to identity endpoint
94-
# For now, return a mock identity with active status
95-
return Identity(auth_context=AuthContext(status="active"))

src/codegen/cli/api/endpoints.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from codegen.cli.api.modal import MODAL_PREFIX
24

35
RUN_ENDPOINT = f"https://{MODAL_PREFIX}--cli-run.modal.run"
@@ -11,3 +13,8 @@
1113
PR_LOOKUP_ENDPOINT = f"https://{MODAL_PREFIX}--cli-pr-lookup.modal.run"
1214
CODEGEN_SYSTEM_PROMPT_URL = "https://gist.githubusercontent.com/jayhack/15681a2ceaccd726f19e6fdb3a44738b/raw/17c08054e3931b3b7fdf424458269c9e607541e8/codegen-system-prompt.txt"
1315
IMPROVE_ENDPOINT = f"https://{MODAL_PREFIX}--cli-improve.modal.run"
16+
MCP_SERVER_ENDPOINT = f"https://{MODAL_PREFIX}--codegen-mcp-server.modal.run/mcp"
17+
18+
# API ENDPOINT
19+
# Prefer explicit override via CODEGEN_API_BASE_URL; fallback to Modal-derived URL for current ENV
20+
API_ENDPOINT = os.environ.get("CODEGEN_API_BASE_URL", f"https://{MODAL_PREFIX}--rest-api.modal.run/")

src/codegen/cli/auth/token_manager.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import os
33
from pathlib import Path
44

5-
from codegen.cli.api.client import RestAPI
65
from codegen.cli.auth.constants import AUTH_FILE, CONFIG_DIR
7-
from codegen.cli.errors import AuthError
86

97

108
class TokenManager:
@@ -22,14 +20,7 @@ def _ensure_config_dir(self):
2220
Path(self.config_dir).mkdir(parents=True, exist_ok=True)
2321

2422
def authenticate_token(self, token: str) -> None:
25-
"""Authenticate the token with the api."""
26-
identity = RestAPI(token).identify()
27-
if not identity:
28-
msg = "No identity found for session"
29-
raise AuthError(msg)
30-
if identity.auth_context.status != "active":
31-
msg = "Current session is not active. API Token may be invalid or may have expired."
32-
raise AuthError(msg)
23+
"""Store the token locally."""
3324
self.save_token(token)
3425

3526
def save_token(self, token: str) -> None:

src/codegen/cli/claude/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Claude Code proxy server and utilities."""

src/codegen/cli/cli.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33

44
from codegen import __version__
55

6+
# Import the actual command functions
7+
from codegen.cli.commands.claude.main import claude
8+
69
# Import config command (still a Typer app)
710
from codegen.cli.commands.config.main import config_command
8-
9-
# Import the actual command functions
1011
from codegen.cli.commands.init.main import init
12+
from codegen.cli.commands.integrations.main import integrations_app
1113
from codegen.cli.commands.login.main import login
1214
from codegen.cli.commands.logout.main import logout
1315
from codegen.cli.commands.mcp.main import mcp
1416
from codegen.cli.commands.profile.main import profile
1517
from codegen.cli.commands.style_debug.main import style_debug
18+
from codegen.cli.commands.tools.main import tools
1619
from codegen.cli.commands.update.main import update
1720

1821
install(show_locals=True)
@@ -29,16 +32,19 @@ def version_callback(value: bool):
2932
main = typer.Typer(name="codegen", help="Codegen CLI - Transform your code with AI.", rich_markup_mode="rich")
3033

3134
# Add individual commands to the main app
35+
main.command("claude", help="Run Claude Code with OpenTelemetry monitoring and logging.")(claude)
3236
main.command("init", help="Initialize or update the Codegen folder.")(init)
3337
main.command("login", help="Store authentication token.")(login)
3438
main.command("logout", help="Clear stored authentication token.")(logout)
3539
main.command("mcp", help="Start the Codegen MCP server.")(mcp)
3640
main.command("profile", help="Display information about the currently authenticated user.")(profile)
3741
main.command("style-debug", help="Debug command to visualize CLI styling (spinners, etc).")(style_debug)
42+
main.command("tools", help="List available tools from the Codegen API.")(tools)
3843
main.command("update", help="Update Codegen to the latest or specified version")(update)
3944

40-
# Config is a group, so add it as a typer
45+
# Add Typer apps as sub-applications
4146
main.add_typer(config_command, name="config")
47+
main.add_typer(integrations_app, name="integrations")
4248

4349

4450
@main.callback()

0 commit comments

Comments
 (0)