margin-mcp 0.10.1__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.
- margin_mcp-0.10.1/CHANGELOG.md +18 -0
- margin_mcp-0.10.1/LICENSE +21 -0
- margin_mcp-0.10.1/MANIFEST.in +14 -0
- margin_mcp-0.10.1/PKG-INFO +200 -0
- margin_mcp-0.10.1/README.md +156 -0
- margin_mcp-0.10.1/pyproject.toml +75 -0
- margin_mcp-0.10.1/requirements-dev.lock +70 -0
- margin_mcp-0.10.1/scripts/check_distributions.py +190 -0
- margin_mcp-0.10.1/scripts/check_drishti_review.py +194 -0
- margin_mcp-0.10.1/scripts/check_installed_product.py +147 -0
- margin_mcp-0.10.1/scripts/check_release_install.py +111 -0
- margin_mcp-0.10.1/setup.cfg +4 -0
- margin_mcp-0.10.1/src/margin/__init__.py +3 -0
- margin_mcp-0.10.1/src/margin/analysis/__init__.py +1 -0
- margin_mcp-0.10.1/src/margin/analysis/calculations.py +241 -0
- margin_mcp-0.10.1/src/margin/analysis/company.py +313 -0
- margin_mcp-0.10.1/src/margin/analysis/facts.py +371 -0
- margin_mcp-0.10.1/src/margin/analysis/presentation.py +152 -0
- margin_mcp-0.10.1/src/margin/analysis/product_reports.py +167 -0
- margin_mcp-0.10.1/src/margin/analysis/ratios.py +266 -0
- margin_mcp-0.10.1/src/margin/analysis/reporting.py +247 -0
- margin_mcp-0.10.1/src/margin/analysis/service.py +177 -0
- margin_mcp-0.10.1/src/margin/analysis/units.py +95 -0
- margin_mcp-0.10.1/src/margin/core/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/core/company_finance.py +513 -0
- margin_mcp-0.10.1/src/margin/core/config.py +64 -0
- margin_mcp-0.10.1/src/margin/core/contracts.py +55 -0
- margin_mcp-0.10.1/src/margin/core/registry.py +363 -0
- margin_mcp-0.10.1/src/margin/core/service.py +1040 -0
- margin_mcp-0.10.1/src/margin/core/validation.py +81 -0
- margin_mcp-0.10.1/src/margin/evidence/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/evidence/results.py +113 -0
- margin_mcp-0.10.1/src/margin/evidence/review_sources.py +111 -0
- margin_mcp-0.10.1/src/margin/evidence/sanitize.py +141 -0
- margin_mcp-0.10.1/src/margin/finance/__init__.py +1 -0
- margin_mcp-0.10.1/src/margin/finance/dcf.py +221 -0
- margin_mcp-0.10.1/src/margin/interfaces/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/interfaces/agent/__init__.py +1 -0
- margin_mcp-0.10.1/src/margin/interfaces/agent/__main__.py +3 -0
- margin_mcp-0.10.1/src/margin/interfaces/agent/backend.py +62 -0
- margin_mcp-0.10.1/src/margin/interfaces/agent/cli.py +202 -0
- margin_mcp-0.10.1/src/margin/interfaces/agent/client.py +231 -0
- margin_mcp-0.10.1/src/margin/interfaces/agent/local_config.py +38 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/__init__.py +1 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/__main__.py +3 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/backend.py +267 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/bridge.py +126 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/policy.py +41 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/profiles.py +317 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/recording.py +62 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/server.py +835 -0
- margin_mcp-0.10.1/src/margin/interfaces/mcp/tools.py +414 -0
- margin_mcp-0.10.1/src/margin/interfaces/workbench/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/interfaces/workbench/app.py +275 -0
- margin_mcp-0.10.1/src/margin/interfaces/workbench/static/app.js +771 -0
- margin_mcp-0.10.1/src/margin/interfaces/workbench/static/favicon.svg +1 -0
- margin_mcp-0.10.1/src/margin/interfaces/workbench/static/index.html +91 -0
- margin_mcp-0.10.1/src/margin/interfaces/workbench/static/style.css +207 -0
- margin_mcp-0.10.1/src/margin/policy/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/policy/ledger.py +74 -0
- margin_mcp-0.10.1/src/margin/protocols/__init__.py +1 -0
- margin_mcp-0.10.1/src/margin/protocols/handoffs.py +69 -0
- margin_mcp-0.10.1/src/margin/protocols/review_flow.py +279 -0
- margin_mcp-0.10.1/src/margin/protocols/schemas.py +185 -0
- margin_mcp-0.10.1/src/margin/protocols/service.py +812 -0
- margin_mcp-0.10.1/src/margin/providers/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/providers/bharatstock.py +62 -0
- margin_mcp-0.10.1/src/margin/providers/drishti.py +304 -0
- margin_mcp-0.10.1/src/margin/providers/synthetic.py +264 -0
- margin_mcp-0.10.1/src/margin/resources/__init__.py +0 -0
- margin_mcp-0.10.1/src/margin/resources/drishti-contracts.json +1414 -0
- margin_mcp-0.10.1/src/margin_mcp.egg-info/PKG-INFO +200 -0
- margin_mcp-0.10.1/src/margin_mcp.egg-info/SOURCES.txt +110 -0
- margin_mcp-0.10.1/src/margin_mcp.egg-info/dependency_links.txt +1 -0
- margin_mcp-0.10.1/src/margin_mcp.egg-info/entry_points.txt +5 -0
- margin_mcp-0.10.1/src/margin_mcp.egg-info/requires.txt +20 -0
- margin_mcp-0.10.1/src/margin_mcp.egg-info/top_level.txt +1 -0
- margin_mcp-0.10.1/tests/conftest.py +46 -0
- margin_mcp-0.10.1/tests/test_adapters.py +248 -0
- margin_mcp-0.10.1/tests/test_agent.py +236 -0
- margin_mcp-0.10.1/tests/test_agent_observers.py +69 -0
- margin_mcp-0.10.1/tests/test_company_analysis.py +257 -0
- margin_mcp-0.10.1/tests/test_company_execution_contract.py +100 -0
- margin_mcp-0.10.1/tests/test_company_reporting.py +296 -0
- margin_mcp-0.10.1/tests/test_core.py +303 -0
- margin_mcp-0.10.1/tests/test_distributions.py +31 -0
- margin_mcp-0.10.1/tests/test_drishti_acceptance.py +28 -0
- margin_mcp-0.10.1/tests/test_finance.py +329 -0
- margin_mcp-0.10.1/tests/test_finance_plan_routing.py +88 -0
- margin_mcp-0.10.1/tests/test_finance_profile.py +290 -0
- margin_mcp-0.10.1/tests/test_finance_repairs.py +422 -0
- margin_mcp-0.10.1/tests/test_financial_view.py +85 -0
- margin_mcp-0.10.1/tests/test_fresh_company_finance.py +587 -0
- margin_mcp-0.10.1/tests/test_function_matrix.py +200 -0
- margin_mcp-0.10.1/tests/test_function_safety.py +116 -0
- margin_mcp-0.10.1/tests/test_local_config.py +19 -0
- margin_mcp-0.10.1/tests/test_mcp.py +848 -0
- margin_mcp-0.10.1/tests/test_mcp_backend.py +532 -0
- margin_mcp-0.10.1/tests/test_mcp_data_policy.py +109 -0
- margin_mcp-0.10.1/tests/test_mcp_profiles.py +132 -0
- margin_mcp-0.10.1/tests/test_network_guard.py +20 -0
- margin_mcp-0.10.1/tests/test_policy_and_evidence.py +212 -0
- margin_mcp-0.10.1/tests/test_product_reports.py +127 -0
- margin_mcp-0.10.1/tests/test_protocols.py +515 -0
- margin_mcp-0.10.1/tests/test_review_flow.py +277 -0
- margin_mcp-0.10.1/tests/test_review_sources.py +158 -0
- margin_mcp-0.10.1/tests/test_typed_previews.py +224 -0
- margin_mcp-0.10.1/tests/test_typed_readiness_dcf.py +248 -0
- margin_mcp-0.10.1/tests/test_typed_reviews.py +747 -0
- margin_mcp-0.10.1/tests/test_validation.py +37 -0
- margin_mcp-0.10.1/tests/test_workbench.py +211 -0
- margin_mcp-0.10.1/tests/test_workbench_views.py +169 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.10.1 — PyPI packaging
|
|
4
|
+
|
|
5
|
+
- Use `margin-mcp` as the public distribution name; Python imports remain `margin`.
|
|
6
|
+
- Add MIT licensing and credits for Rishit Anand, Advait Sharma, Arsalaan Alam and Tanvi Sanghai.
|
|
7
|
+
- Add public installation and own-key MCP setup, package metadata and project links.
|
|
8
|
+
- Keep one software version shared by package metadata and MCP initialization.
|
|
9
|
+
- Separate repository-only research/private-bundle tests from the public source archive.
|
|
10
|
+
- Add wheel/source-archive validation, clean-install checks and Trusted Publishing workflows.
|
|
11
|
+
|
|
12
|
+
Financial calculations, tool contracts and the 39-tool default retain the 0.10.0 behavior.
|
|
13
|
+
|
|
14
|
+
## 0.10.0 — local wheel release
|
|
15
|
+
|
|
16
|
+
Canonical local-allowance and DCF reports, explicit valuation input definitions and
|
|
17
|
+
cross-platform installation checks. Earlier local wheels remain immutable under
|
|
18
|
+
[releases](https://github.com/rishitttt/margin-mcp/tree/main/releases).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rishit Anand, Advait Sharma, Arsalaan Alam, Tanvi Sanghai
|
|
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,14 @@
|
|
|
1
|
+
include LICENSE README.md CHANGELOG.md pyproject.toml requirements-dev.lock
|
|
2
|
+
graft src/margin
|
|
3
|
+
graft tests
|
|
4
|
+
include scripts/check_drishti_review.py
|
|
5
|
+
include scripts/check_installed_product.py scripts/check_distributions.py scripts/check_release_install.py
|
|
6
|
+
prune tests/repository
|
|
7
|
+
prune research
|
|
8
|
+
prune packaging
|
|
9
|
+
prune reports
|
|
10
|
+
prune releases
|
|
11
|
+
prune skills
|
|
12
|
+
prune .github
|
|
13
|
+
global-exclude __pycache__ *.py[cod] .DS_Store
|
|
14
|
+
global-exclude .env .env.* providers.env connection.json *.pem *.key *.sqlite *.sqlite3
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: margin-mcp
|
|
3
|
+
Version: 0.10.1
|
|
4
|
+
Summary: Local MCP server for Indian financial research and deterministic analysis
|
|
5
|
+
Author: Rishit Anand, Advait Sharma, Arsalaan Alam, Tanvi Sanghai
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rishitttt/margin-mcp
|
|
8
|
+
Project-URL: Documentation, https://github.com/rishitttt/margin-mcp/blob/main/docs/mcp.md
|
|
9
|
+
Project-URL: Repository, https://github.com/rishitttt/margin-mcp
|
|
10
|
+
Project-URL: Issues, https://github.com/rishitttt/margin-mcp/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/rishitttt/margin-mcp/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: mcp,finance,india,financial-analysis,research
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: httpx==0.28.1
|
|
27
|
+
Requires-Dist: httpx2==2.13.1
|
|
28
|
+
Requires-Dist: mcp==2.2.0
|
|
29
|
+
Requires-Dist: jsonschema==4.26.0
|
|
30
|
+
Provides-Extra: workbench
|
|
31
|
+
Requires-Dist: fastapi==0.155.0; extra == "workbench"
|
|
32
|
+
Requires-Dist: starlette==1.7.0; extra == "workbench"
|
|
33
|
+
Requires-Dist: uvicorn==0.53.0; extra == "workbench"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest==9.1.1; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-asyncio==1.4.0; extra == "dev"
|
|
37
|
+
Requires-Dist: ruff==0.16.8; extra == "dev"
|
|
38
|
+
Requires-Dist: playwright==1.64.0; extra == "dev"
|
|
39
|
+
Requires-Dist: build==1.6.1; extra == "dev"
|
|
40
|
+
Provides-Extra: release
|
|
41
|
+
Requires-Dist: build==1.6.1; extra == "release"
|
|
42
|
+
Requires-Dist: twine==7.0.0; extra == "release"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
# Margin MCP
|
|
46
|
+
|
|
47
|
+
A local [Model Context Protocol](https://modelcontextprotocol.io/) server for Indian
|
|
48
|
+
listed-company research. Margin combines BharatStock REST and Drishti MCP data with
|
|
49
|
+
deterministic financial calculations, explicit-assumption DCF, and host-assisted
|
|
50
|
+
citation and content-sentiment review.
|
|
51
|
+
|
|
52
|
+
**Python 3.12+ · MIT · Windows, macOS and Linux**
|
|
53
|
+
|
|
54
|
+
The public distribution is **`margin-mcp`**; the Python import is **`margin`**. Version
|
|
55
|
+
**0.10.1**. Earlier local releases used the distribution name `margin-research`.
|
|
56
|
+
[Installation from source](#installation-from-source) is also supported.
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
Create a virtual environment and install from PyPI:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
python -m venv .venv
|
|
64
|
+
# macOS/Linux
|
|
65
|
+
.venv/bin/python -m pip install margin-mcp
|
|
66
|
+
.venv/bin/margin-mcp --help
|
|
67
|
+
# Windows
|
|
68
|
+
.venv\Scripts\python.exe -m pip install margin-mcp
|
|
69
|
+
.venv\Scripts\margin-mcp.exe --help
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
No Node.js/npm, database or model server is required for Margin. Connect it to an MCP
|
|
73
|
+
host that can launch a local stdio server. The default profile exposes 39 tools;
|
|
74
|
+
optional `finance`, `review` and `review-simple` profiles expose focused views.
|
|
75
|
+
|
|
76
|
+
### Connect an MCP host
|
|
77
|
+
|
|
78
|
+
Merge this entry into your host's MCP server configuration. Replace the executable
|
|
79
|
+
path with your installation's absolute path. On Windows use the absolute
|
|
80
|
+
`.venv\\Scripts\\margin-mcp.exe` path with JSON-escaped backslashes.
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"mcpServers": {
|
|
85
|
+
"margin": {
|
|
86
|
+
"command": "/absolute/path/.venv/bin/margin-mcp",
|
|
87
|
+
"args": ["--mode", "live", "--tool-profile", "all"],
|
|
88
|
+
"env": {
|
|
89
|
+
"MARGIN_BHARATSTOCK_REQUESTS": "0",
|
|
90
|
+
"MARGIN_DRISHTI_REQUESTS": "0",
|
|
91
|
+
"MARGIN_DRISHTI_CREDITS": "0"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Start with `margin_status` in the host. This configuration allows local discovery,
|
|
99
|
+
explicit-input calculations and supplied-text reviews while making no provider
|
|
100
|
+
requests. It does not authenticate provider access. Set explicit remaining process
|
|
101
|
+
allowances before authorizing live research; these are not account balances.
|
|
102
|
+
|
|
103
|
+
### Bring your own provider keys
|
|
104
|
+
|
|
105
|
+
Include only the providers you use in a private file outside the checkout:
|
|
106
|
+
|
|
107
|
+
```dotenv
|
|
108
|
+
BHARATSTOCK_API_KEY=YOUR_BHARATSTOCK_KEY
|
|
109
|
+
DRISHTI_API_KEY=YOUR_DRISHTI_KEY
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Protect the file using your operating system's access controls. Add these two args to
|
|
113
|
+
the MCP configuration:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
["--credentials-file", "/absolute/private/providers.env"]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Keys can alternatively be passed through the MCP process environment. Margin does not
|
|
120
|
+
search for `.env` files automatically. Provider subscriptions, entitlements and usage
|
|
121
|
+
belong to each user. Keep keys out of prompts and tool arguments.
|
|
122
|
+
[Credential setup and precedence](https://github.com/rishitttt/margin-mcp/blob/main/docs/local-credentials.md).
|
|
123
|
+
|
|
124
|
+
## What you can do
|
|
125
|
+
|
|
126
|
+
- Retrieve supported financial, price, news, announcement and earnings records.
|
|
127
|
+
- Check company-data readiness and calculate margins, profitability, liquidity,
|
|
128
|
+
cash-flow metrics, growth, CAGR and eligible quarterly TTM.
|
|
129
|
+
- Calculate FCFF, DCF, sensitivities and scenarios from explicit caller inputs.
|
|
130
|
+
- Review supplied passages using host judgments, exact quote/reference checks,
|
|
131
|
+
citation rendering and bounded content-sentiment aggregation.
|
|
132
|
+
|
|
133
|
+
Results preserve units, periods, reporting basis, scope holds and unknown values.
|
|
134
|
+
DCF requires explicit forecasts and assumptions. Citation/sentiment judgments come
|
|
135
|
+
from the host; quote matching does not authenticate an original document or establish
|
|
136
|
+
market-wide investor sentiment. Provider-filtered records can still be irrelevant.
|
|
137
|
+
|
|
138
|
+
Margin retains bounded transient state and optional private diagnostic logs. Owner
|
|
139
|
+
restart loses transient handles and duplicate protection; it does not renew upstream
|
|
140
|
+
quota. Use stable keys to reconcile lost replies.
|
|
141
|
+
[Functions and limits](https://github.com/rishitttt/margin-mcp/blob/main/docs/financial-analysis.md),
|
|
142
|
+
[review workflows](https://github.com/rishitttt/margin-mcp/blob/main/docs/review-workflows.md).
|
|
143
|
+
|
|
144
|
+
## Optional local workbench and CLI
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
python -m pip install "margin-mcp[workbench]"
|
|
148
|
+
margin-workbench --mode synthetic
|
|
149
|
+
# In another terminal, using the same environment:
|
|
150
|
+
margin-agent --expect-mode synthetic status
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The workbench serves a local UI/API at `http://127.0.0.1:8765`. Its synthetic mode uses
|
|
154
|
+
labelled fictional data. `margin-agent` calls that HTTP API; it needs a running
|
|
155
|
+
workbench. Activate the virtual environment or use absolute executable paths for
|
|
156
|
+
these commands. The workbench is optional; the base MCP installation does not need
|
|
157
|
+
FastAPI. The MCP SDK may install server libraries such as uvicorn transitively.
|
|
158
|
+
|
|
159
|
+
`margin-backend` is a separate, optional Unix-socket state owner for MCP frontends on
|
|
160
|
+
macOS/Linux. Windows uses standalone stdio. Backend/frontend versions must match.
|
|
161
|
+
[Standalone/shared setup](https://github.com/rishitttt/margin-mcp/blob/main/docs/mcp.md).
|
|
162
|
+
|
|
163
|
+
The optional [host skill](https://github.com/rishitttt/margin-mcp/tree/main/skills/margin-research)
|
|
164
|
+
is installed separately from the repository; pip does not install or activate skills.
|
|
165
|
+
[CLI and skill guide](https://github.com/rishitttt/margin-mcp/blob/main/docs/agent-interface.md).
|
|
166
|
+
|
|
167
|
+
## Installation from source
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
git clone https://github.com/rishitttt/margin-mcp.git
|
|
171
|
+
cd margin-mcp
|
|
172
|
+
python -m venv .venv
|
|
173
|
+
# Use .venv\Scripts\python.exe on Windows.
|
|
174
|
+
.venv/bin/python -m pip install .
|
|
175
|
+
# Optional UI/API:
|
|
176
|
+
.venv/bin/python -m pip install ".[workbench]"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
To build and validate release artifacts:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
.venv/bin/python -m pip install ".[dev,workbench,release]"
|
|
183
|
+
.venv/bin/python -m build
|
|
184
|
+
.venv/bin/python -m twine check --strict dist/*
|
|
185
|
+
.venv/bin/python scripts/check_distributions.py --version 0.10.1
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Use a clean build directory. The sdist contains the self-contained product tests;
|
|
189
|
+
research/private-bundle tests remain repository-only. Software checks use fictional
|
|
190
|
+
fixtures and make no live provider requests.
|
|
191
|
+
[Release checks](https://github.com/rishitttt/margin-mcp/blob/main/docs/release-checks.md),
|
|
192
|
+
[validation evidence](https://github.com/rishitttt/margin-mcp/blob/main/docs/implementation.md),
|
|
193
|
+
[changelog](https://github.com/rishitttt/margin-mcp/blob/main/CHANGELOG.md).
|
|
194
|
+
|
|
195
|
+
## Authors and license
|
|
196
|
+
|
|
197
|
+
Rishit Anand, Advait Sharma, Arsalaan Alam, Tanvi Sanghai.
|
|
198
|
+
|
|
199
|
+
Licensed under [MIT](https://github.com/rishitttt/margin-mcp/blob/main/LICENSE).
|
|
200
|
+
Provider data and services remain subject to their own terms.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Margin MCP
|
|
2
|
+
|
|
3
|
+
A local [Model Context Protocol](https://modelcontextprotocol.io/) server for Indian
|
|
4
|
+
listed-company research. Margin combines BharatStock REST and Drishti MCP data with
|
|
5
|
+
deterministic financial calculations, explicit-assumption DCF, and host-assisted
|
|
6
|
+
citation and content-sentiment review.
|
|
7
|
+
|
|
8
|
+
**Python 3.12+ · MIT · Windows, macOS and Linux**
|
|
9
|
+
|
|
10
|
+
The public distribution is **`margin-mcp`**; the Python import is **`margin`**. Version
|
|
11
|
+
**0.10.1**. Earlier local releases used the distribution name `margin-research`.
|
|
12
|
+
[Installation from source](#installation-from-source) is also supported.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
Create a virtual environment and install from PyPI:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
python -m venv .venv
|
|
20
|
+
# macOS/Linux
|
|
21
|
+
.venv/bin/python -m pip install margin-mcp
|
|
22
|
+
.venv/bin/margin-mcp --help
|
|
23
|
+
# Windows
|
|
24
|
+
.venv\Scripts\python.exe -m pip install margin-mcp
|
|
25
|
+
.venv\Scripts\margin-mcp.exe --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
No Node.js/npm, database or model server is required for Margin. Connect it to an MCP
|
|
29
|
+
host that can launch a local stdio server. The default profile exposes 39 tools;
|
|
30
|
+
optional `finance`, `review` and `review-simple` profiles expose focused views.
|
|
31
|
+
|
|
32
|
+
### Connect an MCP host
|
|
33
|
+
|
|
34
|
+
Merge this entry into your host's MCP server configuration. Replace the executable
|
|
35
|
+
path with your installation's absolute path. On Windows use the absolute
|
|
36
|
+
`.venv\\Scripts\\margin-mcp.exe` path with JSON-escaped backslashes.
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"margin": {
|
|
42
|
+
"command": "/absolute/path/.venv/bin/margin-mcp",
|
|
43
|
+
"args": ["--mode", "live", "--tool-profile", "all"],
|
|
44
|
+
"env": {
|
|
45
|
+
"MARGIN_BHARATSTOCK_REQUESTS": "0",
|
|
46
|
+
"MARGIN_DRISHTI_REQUESTS": "0",
|
|
47
|
+
"MARGIN_DRISHTI_CREDITS": "0"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Start with `margin_status` in the host. This configuration allows local discovery,
|
|
55
|
+
explicit-input calculations and supplied-text reviews while making no provider
|
|
56
|
+
requests. It does not authenticate provider access. Set explicit remaining process
|
|
57
|
+
allowances before authorizing live research; these are not account balances.
|
|
58
|
+
|
|
59
|
+
### Bring your own provider keys
|
|
60
|
+
|
|
61
|
+
Include only the providers you use in a private file outside the checkout:
|
|
62
|
+
|
|
63
|
+
```dotenv
|
|
64
|
+
BHARATSTOCK_API_KEY=YOUR_BHARATSTOCK_KEY
|
|
65
|
+
DRISHTI_API_KEY=YOUR_DRISHTI_KEY
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Protect the file using your operating system's access controls. Add these two args to
|
|
69
|
+
the MCP configuration:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
["--credentials-file", "/absolute/private/providers.env"]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Keys can alternatively be passed through the MCP process environment. Margin does not
|
|
76
|
+
search for `.env` files automatically. Provider subscriptions, entitlements and usage
|
|
77
|
+
belong to each user. Keep keys out of prompts and tool arguments.
|
|
78
|
+
[Credential setup and precedence](https://github.com/rishitttt/margin-mcp/blob/main/docs/local-credentials.md).
|
|
79
|
+
|
|
80
|
+
## What you can do
|
|
81
|
+
|
|
82
|
+
- Retrieve supported financial, price, news, announcement and earnings records.
|
|
83
|
+
- Check company-data readiness and calculate margins, profitability, liquidity,
|
|
84
|
+
cash-flow metrics, growth, CAGR and eligible quarterly TTM.
|
|
85
|
+
- Calculate FCFF, DCF, sensitivities and scenarios from explicit caller inputs.
|
|
86
|
+
- Review supplied passages using host judgments, exact quote/reference checks,
|
|
87
|
+
citation rendering and bounded content-sentiment aggregation.
|
|
88
|
+
|
|
89
|
+
Results preserve units, periods, reporting basis, scope holds and unknown values.
|
|
90
|
+
DCF requires explicit forecasts and assumptions. Citation/sentiment judgments come
|
|
91
|
+
from the host; quote matching does not authenticate an original document or establish
|
|
92
|
+
market-wide investor sentiment. Provider-filtered records can still be irrelevant.
|
|
93
|
+
|
|
94
|
+
Margin retains bounded transient state and optional private diagnostic logs. Owner
|
|
95
|
+
restart loses transient handles and duplicate protection; it does not renew upstream
|
|
96
|
+
quota. Use stable keys to reconcile lost replies.
|
|
97
|
+
[Functions and limits](https://github.com/rishitttt/margin-mcp/blob/main/docs/financial-analysis.md),
|
|
98
|
+
[review workflows](https://github.com/rishitttt/margin-mcp/blob/main/docs/review-workflows.md).
|
|
99
|
+
|
|
100
|
+
## Optional local workbench and CLI
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
python -m pip install "margin-mcp[workbench]"
|
|
104
|
+
margin-workbench --mode synthetic
|
|
105
|
+
# In another terminal, using the same environment:
|
|
106
|
+
margin-agent --expect-mode synthetic status
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The workbench serves a local UI/API at `http://127.0.0.1:8765`. Its synthetic mode uses
|
|
110
|
+
labelled fictional data. `margin-agent` calls that HTTP API; it needs a running
|
|
111
|
+
workbench. Activate the virtual environment or use absolute executable paths for
|
|
112
|
+
these commands. The workbench is optional; the base MCP installation does not need
|
|
113
|
+
FastAPI. The MCP SDK may install server libraries such as uvicorn transitively.
|
|
114
|
+
|
|
115
|
+
`margin-backend` is a separate, optional Unix-socket state owner for MCP frontends on
|
|
116
|
+
macOS/Linux. Windows uses standalone stdio. Backend/frontend versions must match.
|
|
117
|
+
[Standalone/shared setup](https://github.com/rishitttt/margin-mcp/blob/main/docs/mcp.md).
|
|
118
|
+
|
|
119
|
+
The optional [host skill](https://github.com/rishitttt/margin-mcp/tree/main/skills/margin-research)
|
|
120
|
+
is installed separately from the repository; pip does not install or activate skills.
|
|
121
|
+
[CLI and skill guide](https://github.com/rishitttt/margin-mcp/blob/main/docs/agent-interface.md).
|
|
122
|
+
|
|
123
|
+
## Installation from source
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
git clone https://github.com/rishitttt/margin-mcp.git
|
|
127
|
+
cd margin-mcp
|
|
128
|
+
python -m venv .venv
|
|
129
|
+
# Use .venv\Scripts\python.exe on Windows.
|
|
130
|
+
.venv/bin/python -m pip install .
|
|
131
|
+
# Optional UI/API:
|
|
132
|
+
.venv/bin/python -m pip install ".[workbench]"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
To build and validate release artifacts:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
.venv/bin/python -m pip install ".[dev,workbench,release]"
|
|
139
|
+
.venv/bin/python -m build
|
|
140
|
+
.venv/bin/python -m twine check --strict dist/*
|
|
141
|
+
.venv/bin/python scripts/check_distributions.py --version 0.10.1
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Use a clean build directory. The sdist contains the self-contained product tests;
|
|
145
|
+
research/private-bundle tests remain repository-only. Software checks use fictional
|
|
146
|
+
fixtures and make no live provider requests.
|
|
147
|
+
[Release checks](https://github.com/rishitttt/margin-mcp/blob/main/docs/release-checks.md),
|
|
148
|
+
[validation evidence](https://github.com/rishitttt/margin-mcp/blob/main/docs/implementation.md),
|
|
149
|
+
[changelog](https://github.com/rishitttt/margin-mcp/blob/main/CHANGELOG.md).
|
|
150
|
+
|
|
151
|
+
## Authors and license
|
|
152
|
+
|
|
153
|
+
Rishit Anand, Advait Sharma, Arsalaan Alam, Tanvi Sanghai.
|
|
154
|
+
|
|
155
|
+
Licensed under [MIT](https://github.com/rishitttt/margin-mcp/blob/main/LICENSE).
|
|
156
|
+
Provider data and services remain subject to their own terms.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "margin-mcp"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Local MCP server for Indian financial research and deterministic analysis"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Rishit Anand"},
|
|
14
|
+
{name = "Advait Sharma"},
|
|
15
|
+
{name = "Arsalaan Alam"},
|
|
16
|
+
{name = "Tanvi Sanghai"},
|
|
17
|
+
]
|
|
18
|
+
requires-python = ">=3.12"
|
|
19
|
+
keywords = ["mcp", "finance", "india", "financial-analysis", "research"]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 4 - Beta",
|
|
22
|
+
"Environment :: Console",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Operating System :: MacOS",
|
|
25
|
+
"Operating System :: Microsoft :: Windows",
|
|
26
|
+
"Operating System :: POSIX :: Linux",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
29
|
+
"Programming Language :: Python :: 3.12",
|
|
30
|
+
"Topic :: Office/Business :: Financial",
|
|
31
|
+
]
|
|
32
|
+
dependencies = ["httpx==0.28.1", "httpx2==2.13.1", "mcp==2.2.0", "jsonschema==4.26.0"]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/rishitttt/margin-mcp"
|
|
36
|
+
Documentation = "https://github.com/rishitttt/margin-mcp/blob/main/docs/mcp.md"
|
|
37
|
+
Repository = "https://github.com/rishitttt/margin-mcp"
|
|
38
|
+
Issues = "https://github.com/rishitttt/margin-mcp/issues"
|
|
39
|
+
Changelog = "https://github.com/rishitttt/margin-mcp/blob/main/CHANGELOG.md"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
workbench = ["fastapi==0.155.0", "starlette==1.7.0", "uvicorn==0.53.0"]
|
|
43
|
+
dev = ["pytest==9.1.1", "pytest-asyncio==1.4.0", "ruff==0.16.8", "playwright==1.64.0", "build==1.6.1"]
|
|
44
|
+
release = ["build==1.6.1", "twine==7.0.0"]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
margin-workbench = "margin.interfaces.workbench.app:main"
|
|
48
|
+
margin-agent = "margin.interfaces.agent.cli:main"
|
|
49
|
+
margin-mcp = "margin.interfaces.mcp.server:main"
|
|
50
|
+
margin-backend = "margin.interfaces.mcp.backend:main"
|
|
51
|
+
|
|
52
|
+
[tool.setuptools.packages.find]
|
|
53
|
+
where = ["src"]
|
|
54
|
+
include = ["margin", "margin.*"]
|
|
55
|
+
namespaces = false
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.dynamic]
|
|
58
|
+
version = {attr = "margin.__version__"}
|
|
59
|
+
|
|
60
|
+
[tool.setuptools.package-data]
|
|
61
|
+
"margin.resources" = ["*.json"]
|
|
62
|
+
"margin.interfaces.workbench" = ["static/*"]
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
asyncio_mode = "auto"
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
pythonpath = ["src"]
|
|
68
|
+
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
target-version = "py312"
|
|
71
|
+
line-length = 100
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
75
|
+
ignore = ["E501"]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Tested development/release constraints: Python 3.12 / macOS arm64.
|
|
2
|
+
# Dependency closure of margin-mcp[workbench,dev,release] plus its build backend.
|
|
3
|
+
# Install: python -m pip install -c requirements-dev.lock -e ".[workbench,dev,release]"
|
|
4
|
+
# A version snapshot, not a hashed or cross-platform reproducibility guarantee.
|
|
5
|
+
# Isolated build environments resolve the declared backend requirement separately.
|
|
6
|
+
|
|
7
|
+
annotated-doc==0.0.7
|
|
8
|
+
annotated-types==0.8.0
|
|
9
|
+
anyio==4.16.0
|
|
10
|
+
attrs==26.1.0
|
|
11
|
+
build==1.6.1
|
|
12
|
+
certifi==2026.11.20
|
|
13
|
+
cffi==2.1.1
|
|
14
|
+
charset-normalizer==3.5.3
|
|
15
|
+
click==8.5.1
|
|
16
|
+
cryptography==50.0.2
|
|
17
|
+
docutils==0.23
|
|
18
|
+
fastapi==0.155.0
|
|
19
|
+
greenlet==3.5.6
|
|
20
|
+
h11==0.16.0
|
|
21
|
+
httpcore2==2.13.1
|
|
22
|
+
httpcore==1.0.9
|
|
23
|
+
httpx2==2.13.1
|
|
24
|
+
httpx==0.28.1
|
|
25
|
+
id==1.6.1
|
|
26
|
+
idna==3.20
|
|
27
|
+
iniconfig==2.3.1
|
|
28
|
+
jaraco.classes==3.4.0
|
|
29
|
+
jaraco.context==6.1.2
|
|
30
|
+
jaraco.functools==4.6.0
|
|
31
|
+
jsonschema-specifications==2025.9.1
|
|
32
|
+
jsonschema==4.26.0
|
|
33
|
+
keyring==25.7.0
|
|
34
|
+
markdown-it-py==4.3.0
|
|
35
|
+
mcp-types==2.2.0
|
|
36
|
+
mcp==2.2.0
|
|
37
|
+
mdurl==0.1.2
|
|
38
|
+
more-itertools==11.2.1
|
|
39
|
+
nh3==0.3.8
|
|
40
|
+
opentelemetry-api==1.45.2
|
|
41
|
+
packaging==26.4
|
|
42
|
+
playwright==1.64.0
|
|
43
|
+
pluggy==1.7.0
|
|
44
|
+
pycparser==3.12
|
|
45
|
+
pydantic==2.14.4
|
|
46
|
+
pydantic_core==2.50.5
|
|
47
|
+
pyee==14.0.0
|
|
48
|
+
Pygments==2.21.0
|
|
49
|
+
PyJWT==2.15.1
|
|
50
|
+
pyproject_hooks==1.3.3
|
|
51
|
+
pytest-asyncio==1.4.0
|
|
52
|
+
pytest==9.1.1
|
|
53
|
+
python-multipart==0.0.34
|
|
54
|
+
readme_renderer==46.0
|
|
55
|
+
referencing==0.37.0
|
|
56
|
+
requests-toolbelt==1.0.0
|
|
57
|
+
requests==2.34.2
|
|
58
|
+
rfc3986==2.0.0
|
|
59
|
+
rich==15.0.0
|
|
60
|
+
rpds-py==2026.9.1
|
|
61
|
+
ruff==0.16.8
|
|
62
|
+
setuptools==84.2.0
|
|
63
|
+
sse-starlette==3.7.1
|
|
64
|
+
starlette==1.7.0
|
|
65
|
+
truststore==0.10.5
|
|
66
|
+
twine==7.0.0
|
|
67
|
+
typing-inspection==0.4.5
|
|
68
|
+
typing_extensions==4.16.0
|
|
69
|
+
urllib3==2.8.0
|
|
70
|
+
uvicorn==0.53.0
|