cortexhub 2.1.0__tar.gz → 3.0.0__tar.gz

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.
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.5
2
+ Name: cortexhub
3
+ Version: 3.0.0
4
+ Summary: CortexHub platform SDK: point your agent at the governed LLM router + MCP gateway.
5
+ Project-URL: Homepage, https://cortexhub.ai
6
+ Project-URL: Documentation, https://docs.cortexhub.ai
7
+ Author-email: CortexHub <hello@cortexhub.ai>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,ai,governance,mcp,programmatic
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.10
21
+ Provides-Extra: ai
22
+ Requires-Dist: openai>=1.40; extra == 'ai'
23
+ Provides-Extra: all
24
+ Requires-Dist: mcp>=1.0; extra == 'all'
25
+ Requires-Dist: openai>=1.40; extra == 'all'
26
+ Provides-Extra: mcp
27
+ Requires-Dist: mcp>=1.0; extra == 'mcp'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # cortexhub
31
+
32
+ The **CortexHub platform SDK**. One API key points your existing agent at two
33
+ governed planes:
34
+
35
+ - the **LLM router** (inference) - OpenAI-compatible, so any framework works,
36
+ with routing, caching, compression, governance, and per-agent metering; and
37
+ - the **MCP gateway** (tools + brain + files) - governed, consent-gated,
38
+ injection-defended.
39
+
40
+ You don't rewrite your agent. You change a base URL and drop in one key.
41
+
42
+ [Documentation](https://docs.cortexhub.ai/docs/sdks/overview)
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install cortexhub # zero-dependency core (URLs + headers)
48
+ pip install 'cortexhub[ai]' # + a ready OpenAI-compatible client via cx.llm
49
+ pip install 'cortexhub[mcp]' # + the official MCP client for cx.mcp() sessions
50
+ ```
51
+
52
+ ## The key
53
+
54
+ Onboard an external AI employee in the CortexHub dashboard, grant it
55
+ capabilities, and mint an API key **bound to that agent** (Settings ->
56
+ API keys, or the agent's page). The `cxh_key_...` *is* that agent's identity -
57
+ every call is attributed, governed, and metered to it. No agent argument needed.
58
+
59
+ ```python
60
+ from cortexhub import Cortexhub
61
+ cx = Cortexhub(api_key="cxh_key_...") # or set CORTEXHUB_API_KEY
62
+ ```
63
+
64
+ ## Inference
65
+
66
+ `cx.ai` gives you everything any OpenAI-compatible client needs; `cx.llm` is a
67
+ ready client (extra: `cortexhub[ai]`). Pick the model with the `model` argument:
68
+ `cortexhub/auto` to let CortexHub route per turn, or any model enabled on the
69
+ platform.
70
+
71
+ ```python
72
+ cx.llm.chat.completions.create(model="cortexhub/auto", messages=[{"role": "user", "content": "hi"}])
73
+ cx.llm.responses.create(model="cortexhub/auto", input="hi")
74
+ cx.llm.models.list()
75
+
76
+ cx.ai.base_url # e.g. https://api.cortexhub.ai/v1 (override with CORTEXHUB_ROUTER_URL)
77
+ cx.ai.api_key # your cxh_key_...
78
+ ```
79
+
80
+ ## Use your existing framework
81
+
82
+ The router speaks the OpenAI wire protocol, so every framework integrates the
83
+ same way: point its OpenAI-compatible provider at `cx.ai.base_url`, pass
84
+ `cx.ai.api_key`, and choose a `model`.
85
+
86
+ ```python
87
+ base, key = cx.ai.base_url, cx.ai.api_key
88
+
89
+ # OpenAI SDK / plain
90
+ from openai import OpenAI
91
+ OpenAI(base_url=base, api_key=key).chat.completions.create(model="cortexhub/auto", messages=[...])
92
+
93
+ # LangChain / LangGraph
94
+ from langchain_openai import ChatOpenAI
95
+ ChatOpenAI(base_url=base, api_key=key, model="cortexhub/auto")
96
+
97
+ # CrewAI (LiteLLM under the hood)
98
+ from crewai import LLM
99
+ LLM(model="openai/cortexhub/auto", base_url=base, api_key=key)
100
+
101
+ # AutoGen
102
+ from autogen_ext.models.openai import OpenAIChatCompletionClient
103
+ OpenAIChatCompletionClient(model="cortexhub/auto", base_url=base, api_key=key)
104
+
105
+ # Pydantic AI
106
+ from pydantic_ai.models.openai import OpenAIModel
107
+ from pydantic_ai.providers.openai import OpenAIProvider
108
+ OpenAIModel("cortexhub/auto", provider=OpenAIProvider(base_url=base, api_key=key))
109
+ ```
110
+
111
+ **Anthropic SDK:** the router is OpenAI-compatible, not Anthropic-Messages, so
112
+ point the *OpenAI* client at CortexHub with a `claude-*` model (we route to
113
+ Claude) rather than the Anthropic SDK.
114
+
115
+ ## Tools, brain, and files (MCP gateway)
116
+
117
+ `cx.mcp(agent=...)` returns the MCP connection your agent's loop drives. Any
118
+ MCP-capable framework can register it as a server; the `cortexhub_*` tools
119
+ (governed toolkit calls, brain recall/learn, files search) then appear
120
+ automatically.
121
+
122
+ ```python
123
+ conn = cx.mcp(agent="invoice-bot", end_user_subject="user_42")
124
+ conn.url # https://mcp.cortexhub.ai/v1/mcp
125
+ conn.headers # ready to wire into your MCP transport
126
+ ```
127
+
128
+ ## Authentication modes
129
+
130
+ - **API key** (`api_key=cxh_key_...`, or `CORTEXHUB_API_KEY`) - backends whose
131
+ end users do not have CortexHub accounts. Attest the end user per call with
132
+ `end_user_subject`. Required for `cx.ai` / `cx.llm`.
133
+ - **MCP OAuth client** (`client_id=` / `client_secret=`) - for interactive
134
+ CortexHub users, MCP gateway only.
135
+
136
+ The MCP gateway also accepts MCP OAuth from third-party clients (Claude, Cursor)
137
+ independently of this SDK.
@@ -0,0 +1,108 @@
1
+ # cortexhub
2
+
3
+ The **CortexHub platform SDK**. One API key points your existing agent at two
4
+ governed planes:
5
+
6
+ - the **LLM router** (inference) - OpenAI-compatible, so any framework works,
7
+ with routing, caching, compression, governance, and per-agent metering; and
8
+ - the **MCP gateway** (tools + brain + files) - governed, consent-gated,
9
+ injection-defended.
10
+
11
+ You don't rewrite your agent. You change a base URL and drop in one key.
12
+
13
+ [Documentation](https://docs.cortexhub.ai/docs/sdks/overview)
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install cortexhub # zero-dependency core (URLs + headers)
19
+ pip install 'cortexhub[ai]' # + a ready OpenAI-compatible client via cx.llm
20
+ pip install 'cortexhub[mcp]' # + the official MCP client for cx.mcp() sessions
21
+ ```
22
+
23
+ ## The key
24
+
25
+ Onboard an external AI employee in the CortexHub dashboard, grant it
26
+ capabilities, and mint an API key **bound to that agent** (Settings ->
27
+ API keys, or the agent's page). The `cxh_key_...` *is* that agent's identity -
28
+ every call is attributed, governed, and metered to it. No agent argument needed.
29
+
30
+ ```python
31
+ from cortexhub import Cortexhub
32
+ cx = Cortexhub(api_key="cxh_key_...") # or set CORTEXHUB_API_KEY
33
+ ```
34
+
35
+ ## Inference
36
+
37
+ `cx.ai` gives you everything any OpenAI-compatible client needs; `cx.llm` is a
38
+ ready client (extra: `cortexhub[ai]`). Pick the model with the `model` argument:
39
+ `cortexhub/auto` to let CortexHub route per turn, or any model enabled on the
40
+ platform.
41
+
42
+ ```python
43
+ cx.llm.chat.completions.create(model="cortexhub/auto", messages=[{"role": "user", "content": "hi"}])
44
+ cx.llm.responses.create(model="cortexhub/auto", input="hi")
45
+ cx.llm.models.list()
46
+
47
+ cx.ai.base_url # e.g. https://api.cortexhub.ai/v1 (override with CORTEXHUB_ROUTER_URL)
48
+ cx.ai.api_key # your cxh_key_...
49
+ ```
50
+
51
+ ## Use your existing framework
52
+
53
+ The router speaks the OpenAI wire protocol, so every framework integrates the
54
+ same way: point its OpenAI-compatible provider at `cx.ai.base_url`, pass
55
+ `cx.ai.api_key`, and choose a `model`.
56
+
57
+ ```python
58
+ base, key = cx.ai.base_url, cx.ai.api_key
59
+
60
+ # OpenAI SDK / plain
61
+ from openai import OpenAI
62
+ OpenAI(base_url=base, api_key=key).chat.completions.create(model="cortexhub/auto", messages=[...])
63
+
64
+ # LangChain / LangGraph
65
+ from langchain_openai import ChatOpenAI
66
+ ChatOpenAI(base_url=base, api_key=key, model="cortexhub/auto")
67
+
68
+ # CrewAI (LiteLLM under the hood)
69
+ from crewai import LLM
70
+ LLM(model="openai/cortexhub/auto", base_url=base, api_key=key)
71
+
72
+ # AutoGen
73
+ from autogen_ext.models.openai import OpenAIChatCompletionClient
74
+ OpenAIChatCompletionClient(model="cortexhub/auto", base_url=base, api_key=key)
75
+
76
+ # Pydantic AI
77
+ from pydantic_ai.models.openai import OpenAIModel
78
+ from pydantic_ai.providers.openai import OpenAIProvider
79
+ OpenAIModel("cortexhub/auto", provider=OpenAIProvider(base_url=base, api_key=key))
80
+ ```
81
+
82
+ **Anthropic SDK:** the router is OpenAI-compatible, not Anthropic-Messages, so
83
+ point the *OpenAI* client at CortexHub with a `claude-*` model (we route to
84
+ Claude) rather than the Anthropic SDK.
85
+
86
+ ## Tools, brain, and files (MCP gateway)
87
+
88
+ `cx.mcp(agent=...)` returns the MCP connection your agent's loop drives. Any
89
+ MCP-capable framework can register it as a server; the `cortexhub_*` tools
90
+ (governed toolkit calls, brain recall/learn, files search) then appear
91
+ automatically.
92
+
93
+ ```python
94
+ conn = cx.mcp(agent="invoice-bot", end_user_subject="user_42")
95
+ conn.url # https://mcp.cortexhub.ai/v1/mcp
96
+ conn.headers # ready to wire into your MCP transport
97
+ ```
98
+
99
+ ## Authentication modes
100
+
101
+ - **API key** (`api_key=cxh_key_...`, or `CORTEXHUB_API_KEY`) - backends whose
102
+ end users do not have CortexHub accounts. Attest the end user per call with
103
+ `end_user_subject`. Required for `cx.ai` / `cx.llm`.
104
+ - **MCP OAuth client** (`client_id=` / `client_secret=`) - for interactive
105
+ CortexHub users, MCP gateway only.
106
+
107
+ The MCP gateway also accepts MCP OAuth from third-party clients (Claude, Cursor)
108
+ independently of this SDK.
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "cortexhub"
3
- version = "2.1.0"
4
- description = "MCP gateway client for CortexHub programmatic agent access."
3
+ version = "3.0.0"
4
+ description = "CortexHub platform SDK: point your agent at the governed LLM router + MCP gateway."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
7
7
  license = { text = "MIT" }
@@ -27,6 +27,15 @@ classifiers = [
27
27
  # do client-side governance and that work now lives on the cortexhub gateway.
28
28
  dependencies = []
29
29
 
30
+ # The core is zero-dependency (it computes URLs + headers). The client sugar
31
+ # pulls the standard clients only when you ask for it:
32
+ # pip install 'cortexhub[ai]' -> cx.llm returns a ready openai client
33
+ # pip install 'cortexhub[mcp]' -> the official MCP client for cx.mcp() sessions
34
+ [project.optional-dependencies]
35
+ ai = ["openai>=1.40"]
36
+ mcp = ["mcp>=1.0"]
37
+ all = ["openai>=1.40", "mcp>=1.0"]
38
+
30
39
  [project.urls]
31
40
  Homepage = "https://cortexhub.ai"
32
41
  Documentation = "https://docs.cortexhub.ai"
@@ -64,7 +73,13 @@ ignore = ["E501"]
64
73
  python_version = "3.10"
65
74
  strict = true
66
75
  warn_return_any = true
67
- warn_unused_ignores = true
76
+ # ``openai`` is an optional extra (cortexhub[ai]); the core is zero-dep and
77
+ # imports it lazily inside cx.llm, so a missing stub for it is not an error.
78
+ warn_unused_ignores = false
79
+
80
+ [[tool.mypy.overrides]]
81
+ module = ["openai", "openai.*"]
82
+ ignore_missing_imports = true
68
83
 
69
84
  [tool.uv]
70
85
  python-preference = "only-managed"
@@ -9,9 +9,9 @@ Two gateway authentication paths through one entry point:
9
9
 
10
10
  .. code-block:: python
11
11
 
12
- # Org MCP API key (recommended for backends):
12
+ # Org API key (recommended for backends):
13
13
  from cortexhub import Cortexhub
14
- cx = Cortexhub(api_key="cxh_mcpk_<id>_<secret>")
14
+ cx = Cortexhub(api_key="cxh_key_<id>_<secret>")
15
15
  session = cx.session(agent="invoice-bot", end_user_subject="user_42")
16
16
 
17
17
  # MCP OAuth client (interactive CortexHub users):
@@ -24,15 +24,17 @@ to wire into your MCP transport.
24
24
 
25
25
  from __future__ import annotations
26
26
 
27
+ from .ai import AiGateway
27
28
  from .client import Cortexhub
28
29
  from .errors import APIError, AuthenticationError, ConfigurationError, CortexhubError
29
30
  from .mcp_key import CortexhubKeyClient, McpKeySession
30
31
  from .mcp_oauth import CortexhubMcpOAuthClient, McpOAuthSession, McpOAuthToken
31
32
  from .session import SessionMcp
32
33
 
33
- __version__ = "2.1.0"
34
+ __version__ = "3.0.0"
34
35
  __all__ = [
35
36
  "APIError",
37
+ "AiGateway",
36
38
  "AuthenticationError",
37
39
  "ConfigurationError",
38
40
  "Cortexhub",
@@ -0,0 +1,22 @@
1
+ """SDK base URL configuration."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+
7
+ # MCP gateway (tools + brain + files).
8
+ DEFAULT_URL = "https://mcp.cortexhub.ai"
9
+
10
+ # AI gateway (LLM router). OpenAI-compatible; the client appends
11
+ # ``/chat/completions`` etc. The keyed router is served on the platform API
12
+ # host today; ``router.cortexhub.ai`` is the future canonical host. Override
13
+ # with ``CORTEXHUB_ROUTER_URL``.
14
+ DEFAULT_ROUTER_URL = "https://api.cortexhub.ai/v1"
15
+
16
+
17
+ def base_url() -> str:
18
+ return (os.environ.get("CORTEXHUB_URL") or DEFAULT_URL).rstrip("/")
19
+
20
+
21
+ def router_base_url() -> str:
22
+ return (os.environ.get("CORTEXHUB_ROUTER_URL") or DEFAULT_ROUTER_URL).rstrip("/")
@@ -0,0 +1,63 @@
1
+ """AI gateway (LLM router) configuration + optional client.
2
+
3
+ The router is OpenAI-compatible, so you point any framework's OpenAI-compatible
4
+ provider at :attr:`AiGateway.base_url` with your ``cxh_key_...`` as the API key
5
+ and pass a ``model`` (``cortexhub/auto`` to let CortexHub route, or a specific
6
+ model enabled on the platform). The key is bound to one agent, so there is no
7
+ agent argument - every call is that agent, governed and metered.
8
+
9
+ ``base_url`` + ``api_key`` are all any client needs; :meth:`AiGateway.client`
10
+ (and ``Cortexhub.llm``) is optional sugar that returns a ready ``openai``
11
+ client, and requires the ``cortexhub[ai]`` extra.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from dataclasses import dataclass
17
+ from typing import Any
18
+
19
+ from ._config import router_base_url
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class AiGateway:
24
+ """Everything needed to call the CortexHub LLM router.
25
+
26
+ Point your framework's OpenAI-compatible client here::
27
+
28
+ cx = Cortexhub(api_key="cxh_key_...")
29
+ # base_url + api_key are all you need:
30
+ base = cx.ai.base_url # e.g. https://api.cortexhub.ai/v1
31
+ key = cx.ai.api_key # your cxh_key_...
32
+ """
33
+
34
+ api_key: str
35
+ base_url: str
36
+
37
+ @property
38
+ def headers(self) -> dict[str, str]:
39
+ """Auth header for a raw HTTP client (the OpenAI wire uses Bearer)."""
40
+ return {"Authorization": f"Bearer {self.api_key}"}
41
+
42
+ def client(self, **kwargs: Any) -> Any:
43
+ """Return an ``openai`` client pointed at the router (extra: ``ai``).
44
+
45
+ Extra keyword arguments are passed through to ``openai.OpenAI`` (e.g.
46
+ ``timeout``, ``max_retries``). Raises a clear error if ``openai`` is not
47
+ installed.
48
+ """
49
+ try:
50
+ from openai import OpenAI # type: ignore[import-not-found]
51
+ except ModuleNotFoundError as exc: # pragma: no cover - exercised in tests
52
+ raise ImportError(
53
+ "cx.llm / AiGateway.client() needs the 'openai' package. "
54
+ "Install it with: pip install 'cortexhub[ai]'"
55
+ ) from exc
56
+ return OpenAI(base_url=self.base_url, api_key=self.api_key, **kwargs)
57
+
58
+
59
+ def build_ai_gateway(api_key: str) -> AiGateway:
60
+ return AiGateway(api_key=api_key, base_url=router_base_url())
61
+
62
+
63
+ __all__ = ["AiGateway", "build_ai_gateway"]
@@ -2,12 +2,12 @@
2
2
 
3
3
  Two authentication paths are supported through one entry point:
4
4
 
5
- * **Org MCP API key** (recommended for backends whose end users do
5
+ * **Org API key** (recommended for backends whose end users do
6
6
  not have CortexHub accounts):
7
7
 
8
8
  .. code-block:: python
9
9
 
10
- cx = Cortexhub(api_key="cxh_mcpk_<id>_<secret>")
10
+ cx = Cortexhub(api_key="cxh_key_<id>_<secret>")
11
11
  session = cx.session(agent="invoice-bot", end_user_subject="user_42")
12
12
 
13
13
  * **MCP OAuth client** (when your application signs in CortexHub users):
@@ -24,21 +24,32 @@ to wire into the MCP transport of your choice.
24
24
  from __future__ import annotations
25
25
 
26
26
  import os
27
- from typing import Literal
27
+ from typing import Any, Literal
28
28
 
29
+ from .ai import AiGateway, build_ai_gateway
29
30
  from .errors import ConfigurationError
30
31
  from .mcp_key import CortexhubKeyClient, McpKeySession
31
32
  from .mcp_oauth import CortexhubMcpOAuthClient, McpOAuthSession, McpOAuthToken
33
+ from .session import SessionMcp
32
34
 
33
35
 
34
36
  class Cortexhub:
35
- """MCP gateway client. Pass either an org API key OR OAuth credentials.
37
+ """CortexHub platform client. Pass either an org API key OR OAuth credentials.
38
+
39
+ One key spans both runtime planes:
40
+
41
+ - ``cx.ai`` / ``cx.llm`` -- the LLM router (inference). Point any
42
+ OpenAI-compatible framework at ``cx.ai.base_url`` with your ``cxh_key_``,
43
+ or use ``cx.llm`` for a ready client (extra: ``cortexhub[ai]``).
44
+ - ``cx.mcp(agent=...)`` / ``cx.session(...)`` -- the MCP gateway (tools,
45
+ brain, files) as an MCP connection for your agent.
36
46
 
37
47
  Environment variables (optional fallbacks):
38
48
 
39
- - ``CORTEXHUB_API_KEY`` -- org MCP API key (``cxh_mcpk_*``)
49
+ - ``CORTEXHUB_API_KEY`` -- org API key (``cxh_key_*``)
40
50
  - ``CORTEXHUB_CLIENT_ID`` and ``CORTEXHUB_CLIENT_SECRET`` -- MCP OAuth credentials
41
- - ``CORTEXHUB_URL`` -- gateway base URL (default ``https://mcp.cortexhub.ai``)
51
+ - ``CORTEXHUB_URL`` -- MCP gateway base URL (default ``https://mcp.cortexhub.ai``)
52
+ - ``CORTEXHUB_ROUTER_URL`` -- LLM router base URL (OpenAI-compatible)
42
53
 
43
54
  Exactly one credential path must be present. If both an API key and
44
55
  OAuth credentials are configured, the API key takes precedence.
@@ -79,7 +90,7 @@ class Cortexhub:
79
90
  return
80
91
 
81
92
  raise ConfigurationError(
82
- "Missing credentials. Pass api_key= (org MCP API key) OR "
93
+ "Missing credentials. Pass api_key= (org API key) OR "
83
94
  "client_id= and client_secret= (MCP OAuth client). You can also "
84
95
  "set CORTEXHUB_API_KEY, or CORTEXHUB_CLIENT_ID and "
85
96
  "CORTEXHUB_CLIENT_SECRET."
@@ -152,6 +163,66 @@ class Cortexhub:
152
163
  """OAuth token URL when in OAuth mode. Empty string in key mode."""
153
164
  return self._oauth_backend.token_url if self._oauth_backend else ""
154
165
 
166
+ @property
167
+ def ai(self) -> AiGateway:
168
+ """LLM router config (``base_url`` + ``api_key``). Key mode only.
169
+
170
+ Point any OpenAI-compatible framework at ``cx.ai.base_url`` with
171
+ ``cx.ai.api_key``; pass a ``model`` (``cortexhub/auto`` or a specific
172
+ enabled model). The key is bound to one agent, so no agent argument.
173
+ """
174
+ if self._key_backend is None:
175
+ raise ConfigurationError(
176
+ "cx.ai / cx.llm require an org API key (api_key=cxh_key_...). "
177
+ "The LLM router authenticates with the API key as a Bearer "
178
+ "token; OAuth client credentials are for the MCP gateway."
179
+ )
180
+ return build_ai_gateway(self._key_backend.api_key)
181
+
182
+ @property
183
+ def llm(self) -> Any:
184
+ """A ready OpenAI-compatible client at the router (extra: ``cortexhub[ai]``).
185
+
186
+ .. code-block:: python
187
+
188
+ cx.llm.chat.completions.create(model="cortexhub/auto", messages=[...])
189
+ cx.llm.responses.create(model="cortexhub/auto", input="...")
190
+
191
+ Cached per client. Requires the ``openai`` package.
192
+ """
193
+ cached = getattr(self, "_llm_client", None)
194
+ if cached is None:
195
+ cached = self.ai.client()
196
+ self._llm_client = cached
197
+ return cached
198
+
199
+ def mcp(
200
+ self,
201
+ *,
202
+ agent: str,
203
+ mcp_session_id: str | None = None,
204
+ end_user_subject: str | None = None,
205
+ end_user_display_hint: str | None = None,
206
+ conversation_title: str | None = None,
207
+ last_user_message: str | None = None,
208
+ refresh: bool = False,
209
+ ) -> SessionMcp:
210
+ """MCP gateway connection (``.url`` + ``.headers``) for your agent.
211
+
212
+ A shortcut for ``cx.session(...).mcp``. Wire ``.url`` and ``.headers``
213
+ into your MCP transport; tools, brain, and files appear as governed
214
+ tools. Works in both key and OAuth mode.
215
+ """
216
+ return self.session(
217
+ agent=agent,
218
+ mcp_session_id=mcp_session_id,
219
+ end_user_subject=end_user_subject,
220
+ end_user_display_hint=end_user_display_hint,
221
+ conversation_title=conversation_title,
222
+ last_user_message=last_user_message,
223
+ refresh=refresh,
224
+ ).mcp
225
+
155
226
  def fetch_token(self, *, refresh: bool = False) -> McpOAuthToken:
156
227
  """OAuth-mode only. Mint or refresh an access token directly.
157
228
 
@@ -1,7 +1,7 @@
1
- """Org MCP API key client.
1
+ """Org API key client.
2
2
 
3
3
  Use this when your backend acts on behalf of users who do not have
4
- CortexHub identities. The org MCP API key authenticates the
4
+ CortexHub identities. The org API key authenticates the
5
5
  gateway; the end-user identity is attested per call via
6
6
  ``X-CortexHub-End-User-Subject``. No CortexHub user row is created
7
7
  for the end user, no email is required, no PII is stored.
@@ -22,7 +22,7 @@ _AGENT_HEADER = "X-CortexHub-Agent"
22
22
  _END_USER_SUBJECT_HEADER = "X-CortexHub-End-User-Subject"
23
23
  _END_USER_DISPLAY_HINT_HEADER = "X-CortexHub-End-User-Display-Hint"
24
24
 
25
- _KEY_PREFIX = "cxh_mcpk_"
25
+ _KEY_PREFIX = "cxh_key_"
26
26
 
27
27
 
28
28
  @dataclass
@@ -55,7 +55,7 @@ class McpKeySession:
55
55
 
56
56
 
57
57
  class CortexhubKeyClient:
58
- """Send MCP gateway calls authenticated by an org MCP API key."""
58
+ """Send MCP gateway calls authenticated by an org API key."""
59
59
 
60
60
  def __init__(self, *, api_key: str) -> None:
61
61
  cleaned = (api_key or "").strip()
@@ -63,9 +63,9 @@ class CortexhubKeyClient:
63
63
  raise ValueError("api_key= is required.")
64
64
  if not cleaned.startswith(_KEY_PREFIX):
65
65
  raise ValueError(
66
- f"api_key must start with {_KEY_PREFIX!r}. Org MCP API "
67
- "keys begin with this prefix; if you have an OAuth client_id "
68
- "and client_secret instead, use the OAuth credentials path."
66
+ f"api_key must start with {_KEY_PREFIX!r}. Org API keys begin "
67
+ "with this prefix; if you have an OAuth client_id and "
68
+ "client_secret instead, use the OAuth credentials path."
69
69
  )
70
70
  self.api_key = cleaned
71
71
 
cortexhub-2.1.0/PKG-INFO DELETED
@@ -1,104 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cortexhub
3
- Version: 2.1.0
4
- Summary: MCP gateway client for CortexHub programmatic agent access.
5
- Project-URL: Homepage, https://cortexhub.ai
6
- Project-URL: Documentation, https://docs.cortexhub.ai
7
- Author-email: CortexHub <hello@cortexhub.ai>
8
- License: MIT
9
- License-File: LICENSE
10
- Keywords: agents,ai,governance,mcp,programmatic
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Requires-Python: >=3.10
21
- Description-Content-Type: text/markdown
22
-
23
- # cortexhub
24
-
25
- Official Python client for the **CortexHub MCP gateway**.
26
-
27
- This package builds the URL and headers your MCP transport needs to call
28
- `https://mcp.cortexhub.ai/v1/mcp`. It does not call the CortexHub
29
- Platform API; for organisation, agent, and member management, see the
30
- [Platform API reference](https://docs.cortexhub.ai/docs/rest-api/overview).
31
-
32
- [Documentation](https://docs.cortexhub.ai/docs/sdks/overview)
33
-
34
- ## Install
35
-
36
- ```bash
37
- pip install cortexhub
38
- ```
39
-
40
- ## Two ways to authenticate
41
-
42
- The SDK supports both gateway authentication paths through one entry
43
- point. Pick the one that matches how your application identifies users.
44
-
45
- ### Org MCP API key (recommended for backends)
46
-
47
- Use this when your application has its own users who do not have
48
- CortexHub accounts. The org key authenticates the gateway; the
49
- end-user identity is attested per call.
50
-
51
- Mint the key from **Settings -> MCP API keys** in the
52
- CortexHub dashboard, or programmatically via the Platform API.
53
-
54
- ```python
55
- from cortexhub import Cortexhub
56
-
57
- cx = Cortexhub(api_key="cxh_mcpk_<id>_<secret>")
58
- session = cx.session(
59
- agent="invoice-bot",
60
- end_user_subject="user_42", # required for end-user accountability policies
61
- end_user_display_hint="Alice", # optional, render-only, never persisted
62
- )
63
- # session.mcp.url and session.mcp.headers -> pass to your MCP transport
64
- ```
65
-
66
- ### MCP OAuth client
67
-
68
- Use this when your application signs in CortexHub users interactively.
69
- Create the OAuth client from **Account settings -> MCP OAuth clients** and
70
- copy the `client_id` and `client_secret`.
71
-
72
- ```python
73
- from cortexhub import Cortexhub
74
-
75
- cx = Cortexhub(client_id="...", client_secret="...")
76
- session = cx.session(
77
- agent="helpdesk-bot",
78
- mcp_session_id="chat-42", # optional: groups activity per session
79
- conversation_title="Engineering standup", # optional: context shown in audit
80
- last_user_message="Create a standup page", # optional: context shown in audit
81
- )
82
- ```
83
-
84
- ## Environment variables
85
-
86
- | Variable | Default | Purpose |
87
- |---|---|---|
88
- | `CORTEXHUB_URL` | `https://mcp.cortexhub.ai` | MCP gateway base URL |
89
- | `CORTEXHUB_API_KEY` | - | Org MCP API key (`cxh_mcpk_*`) |
90
- | `CORTEXHUB_CLIENT_ID` | - | MCP OAuth client id |
91
- | `CORTEXHUB_CLIENT_SECRET` | - | MCP OAuth client secret |
92
-
93
- If both `CORTEXHUB_API_KEY` and OAuth credentials are configured, the
94
- API key wins.
95
-
96
- ## What the SDK returns
97
-
98
- In both modes, `session.mcp.url` and `session.mcp.headers` are ready to
99
- wire into the MCP transport of your choice (the official MCP Python SDK,
100
- a custom HTTP client, anything that accepts URL + headers).
101
-
102
- ## License
103
-
104
- MIT.
cortexhub-2.1.0/README.md DELETED
@@ -1,82 +0,0 @@
1
- # cortexhub
2
-
3
- Official Python client for the **CortexHub MCP gateway**.
4
-
5
- This package builds the URL and headers your MCP transport needs to call
6
- `https://mcp.cortexhub.ai/v1/mcp`. It does not call the CortexHub
7
- Platform API; for organisation, agent, and member management, see the
8
- [Platform API reference](https://docs.cortexhub.ai/docs/rest-api/overview).
9
-
10
- [Documentation](https://docs.cortexhub.ai/docs/sdks/overview)
11
-
12
- ## Install
13
-
14
- ```bash
15
- pip install cortexhub
16
- ```
17
-
18
- ## Two ways to authenticate
19
-
20
- The SDK supports both gateway authentication paths through one entry
21
- point. Pick the one that matches how your application identifies users.
22
-
23
- ### Org MCP API key (recommended for backends)
24
-
25
- Use this when your application has its own users who do not have
26
- CortexHub accounts. The org key authenticates the gateway; the
27
- end-user identity is attested per call.
28
-
29
- Mint the key from **Settings -> MCP API keys** in the
30
- CortexHub dashboard, or programmatically via the Platform API.
31
-
32
- ```python
33
- from cortexhub import Cortexhub
34
-
35
- cx = Cortexhub(api_key="cxh_mcpk_<id>_<secret>")
36
- session = cx.session(
37
- agent="invoice-bot",
38
- end_user_subject="user_42", # required for end-user accountability policies
39
- end_user_display_hint="Alice", # optional, render-only, never persisted
40
- )
41
- # session.mcp.url and session.mcp.headers -> pass to your MCP transport
42
- ```
43
-
44
- ### MCP OAuth client
45
-
46
- Use this when your application signs in CortexHub users interactively.
47
- Create the OAuth client from **Account settings -> MCP OAuth clients** and
48
- copy the `client_id` and `client_secret`.
49
-
50
- ```python
51
- from cortexhub import Cortexhub
52
-
53
- cx = Cortexhub(client_id="...", client_secret="...")
54
- session = cx.session(
55
- agent="helpdesk-bot",
56
- mcp_session_id="chat-42", # optional: groups activity per session
57
- conversation_title="Engineering standup", # optional: context shown in audit
58
- last_user_message="Create a standup page", # optional: context shown in audit
59
- )
60
- ```
61
-
62
- ## Environment variables
63
-
64
- | Variable | Default | Purpose |
65
- |---|---|---|
66
- | `CORTEXHUB_URL` | `https://mcp.cortexhub.ai` | MCP gateway base URL |
67
- | `CORTEXHUB_API_KEY` | - | Org MCP API key (`cxh_mcpk_*`) |
68
- | `CORTEXHUB_CLIENT_ID` | - | MCP OAuth client id |
69
- | `CORTEXHUB_CLIENT_SECRET` | - | MCP OAuth client secret |
70
-
71
- If both `CORTEXHUB_API_KEY` and OAuth credentials are configured, the
72
- API key wins.
73
-
74
- ## What the SDK returns
75
-
76
- In both modes, `session.mcp.url` and `session.mcp.headers` are ready to
77
- wire into the MCP transport of your choice (the official MCP Python SDK,
78
- a custom HTTP client, anything that accepts URL + headers).
79
-
80
- ## License
81
-
82
- MIT.
@@ -1,11 +0,0 @@
1
- """SDK base URL configuration."""
2
-
3
- from __future__ import annotations
4
-
5
- import os
6
-
7
- DEFAULT_URL = "https://mcp.cortexhub.ai"
8
-
9
-
10
- def base_url() -> str:
11
- return (os.environ.get("CORTEXHUB_URL") or DEFAULT_URL).rstrip("/")
File without changes
File without changes