v7capital-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,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: v7capital-mcp
3
+ Version: 0.1.0
4
+ Summary: V7 Capital MCP Server — manage cap tables, portfolio, and financials through conversation
5
+ Keywords: mcp,v7capital,asset-management,cap-table,portfolio,ai,claude,llm
6
+ Author: Robert Radoslav
7
+ Author-email: Robert Radoslav <robert.radoslav@protonmail.ch>
8
+ License-Expression: MIT
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Financial and Insurance Industry
11
+ Classifier: Topic :: Office/Business :: Financial
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: click>=8.3.2
15
+ Requires-Dist: fastmcp>=3.2.3
16
+ Requires-Dist: httpx>=0.28.1
17
+ Requires-Python: >=3.12
18
+ Project-URL: Homepage, https://www.v7capital.ro
19
+ Description-Content-Type: text/markdown
20
+
21
+ # V7 Capital MCP Server
22
+
23
+ AI-powered asset management through conversation. Manage cap tables, portfolio investments, companies, and financials via Claude Desktop, Claude Code, or any MCP client.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ uv tool install v7capital-mcp
29
+ ```
30
+
31
+ ## Authentication
32
+
33
+ ```bash
34
+ v7-cli login
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ### Claude Code
40
+ ```bash
41
+ claude mcp add v7capital -- v7-mcp
42
+ ```
43
+
44
+ ### Claude Desktop
45
+ Add to `claude_desktop_config.json`:
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "v7capital": {
50
+ "command": "v7-mcp"
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## Environment Variables
57
+
58
+ | Variable | Default | Description |
59
+ |----------|---------|-------------|
60
+ | `V7_API_URL` | `https://www.v7capital.ro` | API base URL |
61
+
62
+ ## Tools (~48)
63
+
64
+ - **Cap Table**: list/create funds, rounds, stakeholders, securities, transactions; get cap table; list commitments
65
+ - **Companies**: list/create/update companies, income statements, balance sheets, cash flow statements, financial metrics, KPIs, KPI values
66
+ - **Portfolio**: deal pipeline (CRUD), investments (CRU), cash flows (CRU), performance (CRU)
67
+ - **Fund Admin**: list/create/update fee costs
68
+ - **Audit**: list audit logs
@@ -0,0 +1,48 @@
1
+ # V7 Capital MCP Server
2
+
3
+ AI-powered asset management through conversation. Manage cap tables, portfolio investments, companies, and financials via Claude Desktop, Claude Code, or any MCP client.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv tool install v7capital-mcp
9
+ ```
10
+
11
+ ## Authentication
12
+
13
+ ```bash
14
+ v7-cli login
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Claude Code
20
+ ```bash
21
+ claude mcp add v7capital -- v7-mcp
22
+ ```
23
+
24
+ ### Claude Desktop
25
+ Add to `claude_desktop_config.json`:
26
+ ```json
27
+ {
28
+ "mcpServers": {
29
+ "v7capital": {
30
+ "command": "v7-mcp"
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## Environment Variables
37
+
38
+ | Variable | Default | Description |
39
+ |----------|---------|-------------|
40
+ | `V7_API_URL` | `https://www.v7capital.ro` | API base URL |
41
+
42
+ ## Tools (~48)
43
+
44
+ - **Cap Table**: list/create funds, rounds, stakeholders, securities, transactions; get cap table; list commitments
45
+ - **Companies**: list/create/update companies, income statements, balance sheets, cash flow statements, financial metrics, KPIs, KPI values
46
+ - **Portfolio**: deal pipeline (CRUD), investments (CRU), cash flows (CRU), performance (CRU)
47
+ - **Fund Admin**: list/create/update fee costs
48
+ - **Audit**: list audit logs
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "v7capital-mcp"
3
+ version = "0.1.0"
4
+ description = "V7 Capital MCP Server — manage cap tables, portfolio, and financials through conversation"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ authors = [
8
+ { name = "Robert Radoslav", email = "robert.radoslav@protonmail.ch" }
9
+ ]
10
+ requires-python = ">=3.12"
11
+ keywords = ["mcp", "v7capital", "asset-management", "cap-table", "portfolio", "ai", "claude", "llm"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Financial and Insurance Industry",
15
+ "Topic :: Office/Business :: Financial",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ ]
19
+ dependencies = [
20
+ "click>=8.3.2",
21
+ "fastmcp>=3.2.3",
22
+ "httpx>=0.28.1",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://www.v7capital.ro"
27
+
28
+ [project.scripts]
29
+ v7-mcp = "v7capital_mcp.server:main" # stdio — Claude Desktop/Code/Codex
30
+ v7-mcp-http = "v7capital_mcp.server:main_http" # HTTP — ChatGPT / remote clients
31
+ v7-cli = "v7capital_mcp.cli:main"
32
+
33
+ [build-system]
34
+ requires = ["uv_build>=0.8.15,<0.9.0"]
35
+ build-backend = "uv_build"
@@ -0,0 +1 @@
1
+ """V7 Capital MCP Server — AI-powered asset management through conversation."""
@@ -0,0 +1,90 @@
1
+ """
2
+ V7 Capital CLI — Interactive terminal authentication
3
+
4
+ Commands:
5
+ v7-cli login — Login with email/password via /api/auth/login
6
+ v7-cli logout — Delete stored credentials
7
+ v7-cli status — Show current auth status
8
+
9
+ No Supabase credentials needed — auth goes through the V7 Capital API.
10
+ """
11
+
12
+ import getpass
13
+
14
+ import click
15
+ import httpx
16
+
17
+ from .config import API_BASE_URL, REQUEST_TIMEOUT
18
+ from .credentials import load_credentials, save_credentials, delete_credentials
19
+
20
+
21
+ @click.group()
22
+ def main():
23
+ """V7 Capital CLI — Authenticate and manage your MCP connection."""
24
+ pass
25
+
26
+
27
+ @main.command()
28
+ def login():
29
+ """Login to V7 Capital with email and password."""
30
+ email = click.prompt("Email")
31
+ password = getpass.getpass("Password: ")
32
+
33
+ click.echo("Logging in...")
34
+
35
+ try:
36
+ with httpx.Client(timeout=REQUEST_TIMEOUT) as client:
37
+ # Authenticate via V7 Capital API (Supabase handled server-side)
38
+ r = client.post(
39
+ f"{API_BASE_URL}/api/auth/login",
40
+ json={"email": email, "password": password},
41
+ )
42
+
43
+ if r.status_code == 401:
44
+ click.echo("Error: Invalid email or password.", err=True)
45
+ raise SystemExit(1)
46
+
47
+ r.raise_for_status()
48
+ data = r.json()
49
+
50
+ if not data.get("success"):
51
+ click.echo(f"Error: {data.get('error', 'Login failed')}", err=True)
52
+ raise SystemExit(1)
53
+
54
+ save_credentials({
55
+ "access_token": data["access_token"],
56
+ "refresh_token": data["refresh_token"],
57
+ "user_email": data.get("user_email", email),
58
+ })
59
+
60
+ click.echo(f"\n✓ Logged in as {data.get('user_email', email)}")
61
+ click.echo("✓ Credentials saved to ~/.v7capital/credentials.json")
62
+ click.echo(f"\nAPI: {API_BASE_URL}")
63
+
64
+ except httpx.HTTPStatusError as e:
65
+ click.echo(f"Error: API returned {e.response.status_code}", err=True)
66
+ raise SystemExit(1)
67
+ except httpx.ConnectError:
68
+ click.echo(f"Error: Cannot connect to {API_BASE_URL}. Is the server running?", err=True)
69
+ raise SystemExit(1)
70
+
71
+
72
+ @main.command()
73
+ def logout():
74
+ """Delete stored credentials."""
75
+ delete_credentials()
76
+ click.echo("✓ Logged out. Credentials deleted.")
77
+
78
+
79
+ @main.command()
80
+ def status():
81
+ """Show current authentication status."""
82
+ creds = load_credentials()
83
+ if not creds:
84
+ click.echo("Not authenticated. Run 'v7-cli login' first.")
85
+ return
86
+
87
+ click.echo(f"Email: {creds.get('user_email', 'unknown')}")
88
+ click.echo(f"API: {API_BASE_URL}")
89
+ click.echo(f"Token: {'present' if creds.get('access_token') else 'missing'}")
90
+ click.echo(f"Refresh token: {'present' if creds.get('refresh_token') else 'missing'}")
@@ -0,0 +1,105 @@
1
+ """
2
+ V7 Capital MCP Server — HTTP Client
3
+
4
+ Async httpx wrapper that handles:
5
+ - JWT authentication (from ~/.v7capital/credentials.json)
6
+ - Automatic token refresh on 401 via /api/auth/refresh
7
+ - No org/entity context needed (single-org platform)
8
+ """
9
+
10
+ import httpx
11
+
12
+ from .config import API_BASE_URL, REQUEST_TIMEOUT
13
+ from .credentials import load_credentials, save_credentials
14
+
15
+
16
+ class V7Client:
17
+ """HTTP client for V7 Capital API with JWT auth and auto-refresh."""
18
+
19
+ def __init__(self) -> None:
20
+ self.base_url = API_BASE_URL
21
+
22
+ def _get_credentials(self) -> dict:
23
+ """Load credentials or raise descriptive error."""
24
+ creds = load_credentials()
25
+ if not creds or not creds.get("access_token"):
26
+ raise RuntimeError(
27
+ "Not authenticated. Please run 'v7-cli login' in your terminal first."
28
+ )
29
+ return creds
30
+
31
+ @property
32
+ def _headers(self) -> dict:
33
+ """Auth headers from stored credentials."""
34
+ creds = self._get_credentials()
35
+ return {"Authorization": f"Bearer {creds['access_token']}"}
36
+
37
+ async def _refresh_token(self) -> bool:
38
+ """Attempt to refresh JWT via /api/auth/refresh. Returns True if successful."""
39
+ creds = load_credentials()
40
+ if not creds or not creds.get("refresh_token"):
41
+ return False
42
+
43
+ try:
44
+ async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as http:
45
+ r = await http.post(
46
+ f"{self.base_url}/api/auth/refresh",
47
+ json={"refresh_token": creds["refresh_token"]},
48
+ )
49
+ if r.status_code == 200:
50
+ data = r.json()
51
+ creds["access_token"] = data["access_token"]
52
+ creds["refresh_token"] = data["refresh_token"]
53
+ save_credentials(creds)
54
+ return True
55
+ except httpx.HTTPError:
56
+ pass
57
+ return False
58
+
59
+ async def _request(self, method: str, path: str, **kwargs) -> dict:
60
+ """Make HTTP request with auto-refresh on 401."""
61
+ async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as http:
62
+ r = await http.request(
63
+ method,
64
+ f"{self.base_url}{path}",
65
+ headers=self._headers,
66
+ **kwargs,
67
+ )
68
+
69
+ # Auto-refresh on 401
70
+ if r.status_code == 401:
71
+ refreshed = await self._refresh_token()
72
+ if refreshed:
73
+ r = await http.request(
74
+ method,
75
+ f"{self.base_url}{path}",
76
+ headers=self._headers,
77
+ **kwargs,
78
+ )
79
+ else:
80
+ raise RuntimeError(
81
+ "Session expired. Please run 'v7-cli login' again."
82
+ )
83
+
84
+ r.raise_for_status()
85
+ return r.json()
86
+
87
+ async def get(self, path: str, **kwargs) -> dict:
88
+ """GET request to V7 Capital API."""
89
+ return await self._request("GET", path, **kwargs)
90
+
91
+ async def post(self, path: str, data: dict) -> dict:
92
+ """POST request to V7 Capital API."""
93
+ return await self._request("POST", path, json=data)
94
+
95
+ async def put(self, path: str, data: dict) -> dict:
96
+ """PUT request to V7 Capital API."""
97
+ return await self._request("PUT", path, json=data)
98
+
99
+ async def delete(self, path: str) -> dict:
100
+ """DELETE request to V7 Capital API."""
101
+ return await self._request("DELETE", path)
102
+
103
+
104
+ # Singleton instance — shared across all tools
105
+ v7 = V7Client()
@@ -0,0 +1,20 @@
1
+ """
2
+ V7 Capital MCP Server — Configuration
3
+
4
+ API base URL read from environment variable.
5
+ Defaults to production. Override with V7_API_URL for development.
6
+
7
+ No Supabase credentials stored here — auth goes through the API
8
+ (/api/auth/login endpoint handles Supabase internally).
9
+ """
10
+
11
+ import os
12
+
13
+ # V7 Capital API base URL — where the Next.js app is running
14
+ API_BASE_URL = os.environ.get("V7_API_URL", "https://www.v7capital.ro")
15
+
16
+ # Credentials file path — where JWT + refresh token are stored locally
17
+ CREDENTIALS_PATH = os.path.expanduser("~/.v7capital/credentials.json")
18
+
19
+ # HTTP client timeout (seconds)
20
+ REQUEST_TIMEOUT = 30.0
@@ -0,0 +1,49 @@
1
+ """
2
+ V7 Capital MCP Server — Credentials Management
3
+
4
+ Reads/writes JWT + refresh token to ~/.v7capital/credentials.json.
5
+ File permissions set to 600 (owner read/write only).
6
+ Password is NEVER stored — only tokens.
7
+ """
8
+
9
+ import json
10
+ import os
11
+ from pathlib import Path
12
+ from typing import TypedDict
13
+
14
+ from .config import CREDENTIALS_PATH
15
+
16
+
17
+ class Credentials(TypedDict):
18
+ access_token: str
19
+ refresh_token: str
20
+ user_email: str
21
+
22
+
23
+ def load_credentials() -> Credentials | None:
24
+ """Load credentials from ~/.v7capital/credentials.json. Returns None if not found."""
25
+ path = Path(CREDENTIALS_PATH)
26
+ if not path.exists():
27
+ return None
28
+ try:
29
+ with open(path) as f:
30
+ return json.load(f)
31
+ except (json.JSONDecodeError, KeyError):
32
+ return None
33
+
34
+
35
+ def save_credentials(creds: Credentials) -> None:
36
+ """Save credentials to ~/.v7capital/credentials.json with chmod 600."""
37
+ path = Path(CREDENTIALS_PATH)
38
+ path.parent.mkdir(parents=True, exist_ok=True)
39
+ with open(path, "w") as f:
40
+ json.dump(creds, f, indent=2)
41
+ # Owner read/write only — no group/other access
42
+ os.chmod(path, 0o600)
43
+
44
+
45
+ def delete_credentials() -> None:
46
+ """Delete credentials file (logout)."""
47
+ path = Path(CREDENTIALS_PATH)
48
+ if path.exists():
49
+ path.unlink()
@@ -0,0 +1,41 @@
1
+ """
2
+ V7 Capital MCP Server
3
+
4
+ FastMCP instance with all tools registered.
5
+ Entrypoint: v7-mcp (stdio transport for Claude Desktop/Code/Cursor)
6
+ """
7
+
8
+ from fastmcp import FastMCP
9
+
10
+ mcp = FastMCP(
11
+ "V7 Capital",
12
+ instructions=(
13
+ "V7 Capital Asset Manager — manage cap tables, portfolio investments, companies, and financials through conversation.\n\n"
14
+ "IMPORTANT: Before using any tools, the user must have run 'v7-cli login' in their terminal.\n\n"
15
+ "This is a single-organization platform (V7 Capital). No context switching needed — all tools operate on V7 Capital data directly.\n\n"
16
+ "Domains:\n"
17
+ "- Cap Table: funds, rounds, stakeholders, securities, transactions, commitments\n"
18
+ "- Companies: company profiles + financial statements (income, balance, cash flow, metrics, KPIs)\n"
19
+ "- Portfolio: deal pipeline, investments, cash flows, performance\n"
20
+ "- Fund Admin: fee costs\n"
21
+ "- Audit: view change history"
22
+ ),
23
+ mask_error_details=True,
24
+ )
25
+
26
+ # Register all tools by importing tool modules
27
+ from .tools import captable # noqa: F401, E402
28
+ from .tools import companies # noqa: F401, E402
29
+ from .tools import portfolio # noqa: F401, E402
30
+ from .tools import fees # noqa: F401, E402
31
+ from .tools import audit # noqa: F401, E402
32
+
33
+
34
+ def main():
35
+ """Entrypoint for v7-mcp command. Runs stdio transport for Claude Desktop/Code/Codex."""
36
+ mcp.run()
37
+
38
+
39
+ def main_http():
40
+ """Entrypoint for v7-mcp-http command. Runs Streamable HTTP transport for ChatGPT / remote clients."""
41
+ mcp.run(transport="http", host="0.0.0.0", port=8811)
@@ -0,0 +1 @@
1
+ """V7 Capital MCP Tools — organized by domain."""
@@ -0,0 +1,47 @@
1
+ """
2
+ Audit Trail tools — read-only access to the audit log.
3
+
4
+ Supports filtering by table name, action type, and date range.
5
+ """
6
+
7
+ from ..server import mcp
8
+ from ..client import v7
9
+
10
+
11
+ # ==========================================
12
+ # Audit Logs
13
+ # ==========================================
14
+
15
+ @mcp.tool(annotations={"readOnlyHint": True})
16
+ async def list_audit_logs(
17
+ table_name: str | None = None,
18
+ action: str | None = None,
19
+ date_from: str | None = None,
20
+ date_to: str | None = None,
21
+ ) -> str:
22
+ """List audit log entries with optional filters. Date format: YYYY-MM-DD."""
23
+ params: dict = {}
24
+ if table_name is not None:
25
+ params["tableName"] = table_name
26
+ if action is not None:
27
+ params["action"] = action
28
+ if date_from is not None:
29
+ params["dateFrom"] = date_from
30
+ if date_to is not None:
31
+ params["dateTo"] = date_to
32
+
33
+ result = await v7.get("/api/assetmanager/audit", params=params)
34
+ items = result.get("data", [])
35
+
36
+ if not items:
37
+ return "No audit log entries found."
38
+
39
+ lines = [f"Audit Logs ({len(items)}):"]
40
+ for a in items:
41
+ lines.append(
42
+ f" - id={a.get('id', '—')} | table={a.get('tableName', '—')} | "
43
+ f"action={a.get('action', '—')} | date={a.get('createdAt', '—')} | "
44
+ f"user={a.get('userId', '—')}"
45
+ )
46
+
47
+ return "\n".join(lines)