sugra-api-mcp 0.1.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,24 @@
1
+ name: Deploy MCP to APP VM
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - "sugra_api_mcp/**"
8
+ - "pyproject.toml"
9
+ - ".github/workflows/deploy-app-vm.yml"
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ deploy:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Deploy via SSH
18
+ uses: appleboy/ssh-action@v1.2.0
19
+ with:
20
+ host: ${{ secrets.APP_VM_HOST }}
21
+ username: ${{ secrets.APP_VM_USER }}
22
+ key: ${{ secrets.APP_VM_SSH_KEY }}
23
+ script: |
24
+ sudo /usr/local/bin/sugra-mcp-deploy
@@ -0,0 +1,25 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ environment: pypi
12
+ permissions:
13
+ id-token: write
14
+ contents: read
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.13"
20
+ - name: Build
21
+ run: |
22
+ python -m pip install --upgrade pip build
23
+ python -m build
24
+ - name: Publish to PyPI (trusted publishing)
25
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,28 @@
1
+ name: Publish to TestPyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - "test-v*"
8
+
9
+ jobs:
10
+ build-and-publish:
11
+ runs-on: ubuntu-latest
12
+ environment: testpypi
13
+ permissions:
14
+ id-token: write
15
+ contents: read
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.13"
21
+ - name: Build
22
+ run: |
23
+ python -m pip install --upgrade pip build
24
+ python -m build
25
+ - name: Publish to TestPyPI
26
+ uses: pypa/gh-action-pypi-publish@release/v1
27
+ with:
28
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,42 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.13", "3.14"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Set up Python ${{ matrix.python-version }}
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ - name: Install
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install -e ".[dev,http]"
25
+ - name: Ruff
26
+ run: ruff check sugra_api_mcp
27
+ - name: Import check
28
+ run: python -c "import sugra_api_mcp; from sugra_api_mcp import tools"
29
+ - name: Tools registered
30
+ env:
31
+ SUGRA_API_KEY: dummy_test_key
32
+ run: |
33
+ python -c "
34
+ import asyncio
35
+ from sugra_api_mcp import tools
36
+ from sugra_api_mcp.server import mcp
37
+ async def main():
38
+ t = await mcp.list_tools()
39
+ assert len(t) == 17, f'Expected 17 tools, got {len(t)}'
40
+ print(f'OK: {len(t)} tools registered')
41
+ asyncio.run(main())
42
+ "
@@ -0,0 +1,31 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.so
5
+ .Python
6
+ build/
7
+ dist/
8
+ *.egg-info/
9
+ .eggs/
10
+ *.egg
11
+
12
+ .venv/
13
+ venv/
14
+ env/
15
+ ENV/
16
+
17
+ .pytest_cache/
18
+ .mypy_cache/
19
+ .ruff_cache/
20
+ .coverage
21
+ htmlcov/
22
+ .tox/
23
+
24
+ .env
25
+ .env.local
26
+ *.log
27
+
28
+ .vscode/
29
+ .idea/
30
+ *.swp
31
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sugra Systems, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: sugra-api-mcp
3
+ Version: 0.1.0
4
+ Summary: Sugra API MCP server - unified access to 518+ intelligence endpoints from Claude Desktop, Cursor, Zed, and any MCP-compatible client
5
+ Project-URL: Homepage, https://sugra.ai
6
+ Project-URL: Documentation, https://docs.sugra.ai
7
+ Project-URL: Repository, https://github.com/Sugra-Systems/prod-sugra-ai-MCP
8
+ Project-URL: Issues, https://github.com/Sugra-Systems/prod-sugra-ai-MCP/issues
9
+ Author-email: "Sugra Systems, Inc." <support@sugra.systems>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: ai-agents,claude,data,finance,llm,macro,mcp,model-context-protocol,sugra
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Office/Business :: Financial
21
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
22
+ Requires-Python: >=3.13
23
+ Requires-Dist: httpx>=0.27
24
+ Requires-Dist: mcp>=1.2.0
25
+ Requires-Dist: pydantic>=2.9
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.11; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
29
+ Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.7; extra == 'dev'
32
+ Provides-Extra: http
33
+ Requires-Dist: fastapi>=0.115; extra == 'http'
34
+ Requires-Dist: uvicorn[standard]>=0.30; extra == 'http'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # sugra-api-mcp
38
+
39
+ [![PyPI](https://img.shields.io/pypi/v/sugra-api-mcp.svg)](https://pypi.org/project/sugra-api-mcp/)
40
+ [![Python](https://img.shields.io/pypi/pyversions/sugra-api-mcp.svg)](https://pypi.org/project/sugra-api-mcp/)
41
+ [![License](https://img.shields.io/pypi/l/sugra-api-mcp.svg)](https://github.com/Sugra-Systems/prod-sugra-ai-MCP/blob/main/LICENSE)
42
+
43
+ Official [Model Context Protocol](https://modelcontextprotocol.io) server for the [Sugra API](https://sugra.ai) - unified access to 518+ intelligence endpoints spanning financial markets, macroeconomics, fundamentals, government data, physical world signals, and news.
44
+
45
+ Use it from Claude Desktop, Cursor, Zed, Cline, claude.ai, or any MCP-compatible agent.
46
+
47
+ ## What you get
48
+
49
+ 17 tools covering the full Sugra API:
50
+
51
+ | Category | Tools |
52
+ |---|---|
53
+ | Markets | `get_market_price`, `get_historical_prices`, `get_market_overview`, `search_symbol`, `get_prediction_market` |
54
+ | Fundamentals | `get_company_overview`, `get_company_filings` |
55
+ | Macro | `get_macro_indicator`, `get_central_bank_rate`, `search_economic_series` |
56
+ | Government | `get_government_spending`, `get_treasury_data` |
57
+ | Physical world | `get_weather`, `get_environmental_data` |
58
+ | News | `get_news` |
59
+ | Discovery | `search_endpoint`, `call_endpoint` (covers all 518 endpoints) |
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install sugra-api-mcp
65
+ ```
66
+
67
+ Get a free API key at [app.sugra.ai/settings/billing](https://app.sugra.ai/settings/billing) (Free tier: 50 req/day).
68
+
69
+ ## Usage with Claude Desktop (stdio)
70
+
71
+ Add to `claude_desktop_config.json`:
72
+
73
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
74
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
75
+
76
+ ```json
77
+ {
78
+ "mcpServers": {
79
+ "sugra": {
80
+ "command": "python",
81
+ "args": ["-m", "sugra_api_mcp"],
82
+ "env": {
83
+ "SUGRA_API_KEY": "sugra_xxx_yourkey..."
84
+ }
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ Restart Claude Desktop. Sugra tools appear in the tools menu.
91
+
92
+ ## Usage with Cursor, Zed, Cline
93
+
94
+ Same stdio config as above, in the respective MCP settings file.
95
+
96
+ ## Usage over HTTP (claude.ai, remote agents)
97
+
98
+ If you prefer not to install anything locally, use the hosted Streamable HTTP endpoint:
99
+
100
+ ```
101
+ https://app.sugra.ai/mcp
102
+ ```
103
+
104
+ Add to claude.ai or any Streamable HTTP MCP client with `Authorization: Bearer sugra_xxx_...` header.
105
+
106
+ ## Environment variables
107
+
108
+ | Variable | Required | Default | Description |
109
+ |---|---|---|---|
110
+ | `SUGRA_API_KEY` | Yes | - | Your Sugra API key |
111
+ | `SUGRA_API_BASE` | No | `https://sugra.ai` | Override for self-hosted or beta environments |
112
+ | `SUGRA_TIMEOUT` | No | `30` | Request timeout in seconds |
113
+
114
+ ## Examples
115
+
116
+ Ask Claude:
117
+
118
+ - "What's Bitcoin's current price and how did it move this week?"
119
+ - "Show me Apple's income statement and debt profile."
120
+ - "Compare US vs Germany CPI over the last 5 years."
121
+ - "What's the Fed funds rate today, and what was the last change?"
122
+ - "Find all Sugra endpoints related to shipping or vessels."
123
+
124
+ ## Development
125
+
126
+ ```bash
127
+ git clone https://github.com/Sugra-Systems/prod-sugra-ai-MCP
128
+ cd prod-sugra-ai-MCP
129
+ pip install -e ".[dev,http]"
130
+ export SUGRA_API_KEY=sugra_...
131
+ python -m sugra_api_mcp # stdio mode
132
+ python -m sugra_api_mcp --transport streamable-http --port 8001 # HTTP mode
133
+ ```
134
+
135
+ Run tests:
136
+
137
+ ```bash
138
+ pytest
139
+ ```
140
+
141
+ ## License
142
+
143
+ MIT © Sugra Systems, Inc.
@@ -0,0 +1,107 @@
1
+ # sugra-api-mcp
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/sugra-api-mcp.svg)](https://pypi.org/project/sugra-api-mcp/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/sugra-api-mcp.svg)](https://pypi.org/project/sugra-api-mcp/)
5
+ [![License](https://img.shields.io/pypi/l/sugra-api-mcp.svg)](https://github.com/Sugra-Systems/prod-sugra-ai-MCP/blob/main/LICENSE)
6
+
7
+ Official [Model Context Protocol](https://modelcontextprotocol.io) server for the [Sugra API](https://sugra.ai) - unified access to 518+ intelligence endpoints spanning financial markets, macroeconomics, fundamentals, government data, physical world signals, and news.
8
+
9
+ Use it from Claude Desktop, Cursor, Zed, Cline, claude.ai, or any MCP-compatible agent.
10
+
11
+ ## What you get
12
+
13
+ 17 tools covering the full Sugra API:
14
+
15
+ | Category | Tools |
16
+ |---|---|
17
+ | Markets | `get_market_price`, `get_historical_prices`, `get_market_overview`, `search_symbol`, `get_prediction_market` |
18
+ | Fundamentals | `get_company_overview`, `get_company_filings` |
19
+ | Macro | `get_macro_indicator`, `get_central_bank_rate`, `search_economic_series` |
20
+ | Government | `get_government_spending`, `get_treasury_data` |
21
+ | Physical world | `get_weather`, `get_environmental_data` |
22
+ | News | `get_news` |
23
+ | Discovery | `search_endpoint`, `call_endpoint` (covers all 518 endpoints) |
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install sugra-api-mcp
29
+ ```
30
+
31
+ Get a free API key at [app.sugra.ai/settings/billing](https://app.sugra.ai/settings/billing) (Free tier: 50 req/day).
32
+
33
+ ## Usage with Claude Desktop (stdio)
34
+
35
+ Add to `claude_desktop_config.json`:
36
+
37
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
38
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "sugra": {
44
+ "command": "python",
45
+ "args": ["-m", "sugra_api_mcp"],
46
+ "env": {
47
+ "SUGRA_API_KEY": "sugra_xxx_yourkey..."
48
+ }
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ Restart Claude Desktop. Sugra tools appear in the tools menu.
55
+
56
+ ## Usage with Cursor, Zed, Cline
57
+
58
+ Same stdio config as above, in the respective MCP settings file.
59
+
60
+ ## Usage over HTTP (claude.ai, remote agents)
61
+
62
+ If you prefer not to install anything locally, use the hosted Streamable HTTP endpoint:
63
+
64
+ ```
65
+ https://app.sugra.ai/mcp
66
+ ```
67
+
68
+ Add to claude.ai or any Streamable HTTP MCP client with `Authorization: Bearer sugra_xxx_...` header.
69
+
70
+ ## Environment variables
71
+
72
+ | Variable | Required | Default | Description |
73
+ |---|---|---|---|
74
+ | `SUGRA_API_KEY` | Yes | - | Your Sugra API key |
75
+ | `SUGRA_API_BASE` | No | `https://sugra.ai` | Override for self-hosted or beta environments |
76
+ | `SUGRA_TIMEOUT` | No | `30` | Request timeout in seconds |
77
+
78
+ ## Examples
79
+
80
+ Ask Claude:
81
+
82
+ - "What's Bitcoin's current price and how did it move this week?"
83
+ - "Show me Apple's income statement and debt profile."
84
+ - "Compare US vs Germany CPI over the last 5 years."
85
+ - "What's the Fed funds rate today, and what was the last change?"
86
+ - "Find all Sugra endpoints related to shipping or vessels."
87
+
88
+ ## Development
89
+
90
+ ```bash
91
+ git clone https://github.com/Sugra-Systems/prod-sugra-ai-MCP
92
+ cd prod-sugra-ai-MCP
93
+ pip install -e ".[dev,http]"
94
+ export SUGRA_API_KEY=sugra_...
95
+ python -m sugra_api_mcp # stdio mode
96
+ python -m sugra_api_mcp --transport streamable-http --port 8001 # HTTP mode
97
+ ```
98
+
99
+ Run tests:
100
+
101
+ ```bash
102
+ pytest
103
+ ```
104
+
105
+ ## License
106
+
107
+ MIT © Sugra Systems, Inc.
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sugra-api-mcp"
7
+ version = "0.1.0"
8
+ description = "Sugra API MCP server - unified access to 518+ intelligence endpoints from Claude Desktop, Cursor, Zed, and any MCP-compatible client"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "Sugra Systems, Inc.", email = "support@sugra.systems" },
13
+ ]
14
+ requires-python = ">=3.13"
15
+ keywords = [
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "sugra",
19
+ "finance",
20
+ "macro",
21
+ "claude",
22
+ "ai-agents",
23
+ "llm",
24
+ "data",
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Intended Audience :: Developers",
29
+ "Intended Audience :: Financial and Insurance Industry",
30
+ "License :: OSI Approved :: MIT License",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3.14",
34
+ "Topic :: Office/Business :: Financial",
35
+ "Topic :: Scientific/Engineering :: Information Analysis",
36
+ ]
37
+ dependencies = [
38
+ "mcp>=1.2.0",
39
+ "httpx>=0.27",
40
+ "pydantic>=2.9",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ http = [
45
+ "fastapi>=0.115",
46
+ "uvicorn[standard]>=0.30",
47
+ ]
48
+ dev = [
49
+ "pytest>=8.0",
50
+ "pytest-asyncio>=0.23",
51
+ "pytest-httpx>=0.30",
52
+ "ruff>=0.7",
53
+ "mypy>=1.11",
54
+ ]
55
+
56
+ [project.scripts]
57
+ sugra-api-mcp = "sugra_api_mcp.__main__:main"
58
+
59
+ [project.urls]
60
+ Homepage = "https://sugra.ai"
61
+ Documentation = "https://docs.sugra.ai"
62
+ Repository = "https://github.com/Sugra-Systems/prod-sugra-ai-MCP"
63
+ Issues = "https://github.com/Sugra-Systems/prod-sugra-ai-MCP/issues"
64
+
65
+ [tool.hatch.build.targets.wheel]
66
+ packages = ["sugra_api_mcp"]
67
+
68
+ [tool.ruff]
69
+ line-length = 100
70
+ target-version = "py313"
71
+
72
+ [tool.ruff.lint]
73
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
74
+ ignore = ["E501"]
75
+
76
+ [tool.pytest.ini_options]
77
+ asyncio_mode = "auto"
78
+ testpaths = ["tests"]
79
+
80
+ [tool.mypy]
81
+ python_version = "3.13"
82
+ strict = true
83
+ warn_unused_configs = true
@@ -0,0 +1,7 @@
1
+ """Sugra API MCP server.
2
+
3
+ Official Model Context Protocol server for the Sugra API.
4
+ See https://github.com/Sugra-Systems/prod-sugra-ai-MCP for usage.
5
+ """
6
+
7
+ __version__ = "0.1.0"
@@ -0,0 +1,48 @@
1
+ """Entry point: `python -m sugra_api_mcp` or `sugra-api-mcp` CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+ from typing import Literal
8
+
9
+
10
+ def main() -> None:
11
+ parser = argparse.ArgumentParser(
12
+ prog="sugra-api-mcp",
13
+ description="Sugra API MCP server",
14
+ )
15
+ parser.add_argument(
16
+ "--transport",
17
+ choices=["stdio", "streamable-http"],
18
+ default="stdio",
19
+ help="MCP transport (default: stdio for Claude Desktop / Cursor / Zed)",
20
+ )
21
+ parser.add_argument(
22
+ "--host",
23
+ default="127.0.0.1",
24
+ help="Bind host for streamable-http (default: 127.0.0.1)",
25
+ )
26
+ parser.add_argument(
27
+ "--port",
28
+ type=int,
29
+ default=8001,
30
+ help="Bind port for streamable-http (default: 8001)",
31
+ )
32
+ args = parser.parse_args()
33
+
34
+ # Import tools to register them with the FastMCP instance.
35
+ from . import tools # noqa: F401
36
+ from .server import mcp
37
+
38
+ transport: Literal["stdio", "streamable-http"] = args.transport
39
+ if transport == "stdio":
40
+ mcp.run(transport="stdio")
41
+ else:
42
+ mcp.settings.host = args.host
43
+ mcp.settings.port = args.port
44
+ mcp.run(transport="streamable-http")
45
+
46
+
47
+ if __name__ == "__main__":
48
+ sys.exit(main())
@@ -0,0 +1,52 @@
1
+ """Async HTTP client for the Sugra API."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from .config import Config
10
+
11
+
12
+ class SugraClient:
13
+ """Thin async wrapper over the Sugra API with x-api-key auth."""
14
+
15
+ def __init__(self, config: Config) -> None:
16
+ self._config = config
17
+ self._client = httpx.AsyncClient(
18
+ base_url=config.api_base,
19
+ headers={
20
+ "x-api-key": config.api_key,
21
+ "User-Agent": "sugra-api-mcp/0.1.0",
22
+ "Accept": "application/json",
23
+ },
24
+ timeout=config.timeout,
25
+ )
26
+
27
+ async def get(self, path: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
28
+ clean_params = {k: v for k, v in (params or {}).items() if v is not None}
29
+ response = await self._client.get(path, params=clean_params)
30
+ return self._handle(response)
31
+
32
+ async def post(self, path: str, json: dict[str, Any] | None = None) -> dict[str, Any]:
33
+ response = await self._client.post(path, json=json or {})
34
+ return self._handle(response)
35
+
36
+ @staticmethod
37
+ def _handle(response: httpx.Response) -> dict[str, Any]:
38
+ try:
39
+ payload = response.json()
40
+ except ValueError:
41
+ payload = {"error": response.text[:500]}
42
+ if response.status_code >= 400:
43
+ error = payload.get("error") if isinstance(payload, dict) else str(payload)
44
+ return {
45
+ "error": error or f"HTTP {response.status_code}",
46
+ "status_code": response.status_code,
47
+ "url": str(response.request.url),
48
+ }
49
+ return payload
50
+
51
+ async def aclose(self) -> None:
52
+ await self._client.aclose()
@@ -0,0 +1,27 @@
1
+ """Configuration loading from environment variables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from dataclasses import dataclass
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class Config:
11
+ api_base: str
12
+ api_key: str
13
+ timeout: float
14
+
15
+
16
+ def load_config() -> Config:
17
+ api_key = os.environ.get("SUGRA_API_KEY", "").strip()
18
+ if not api_key:
19
+ raise RuntimeError(
20
+ "SUGRA_API_KEY environment variable is required. "
21
+ "Get one free at https://app.sugra.ai/settings/billing"
22
+ )
23
+ return Config(
24
+ api_base=os.environ.get("SUGRA_API_BASE", "https://sugra.ai").rstrip("/"),
25
+ api_key=api_key,
26
+ timeout=float(os.environ.get("SUGRA_TIMEOUT", "30")),
27
+ )