Margin MCP
A local Model Context Protocol server for Indian listed-company research. Margin combines BharatStock REST and Drishti MCP data with deterministic financial calculations, explicit-assumption DCF, and host-assisted citation and content-sentiment review.
Python 3.12+ · MIT · Windows, macOS and Linux
The public distribution is margin-mcp; the Python import is margin. Version
0.10.1. Earlier local releases used the distribution name margin-research.
Installation from source is also supported.
Install
Create a virtual environment and install from PyPI:
python -m venv .venv
# macOS/Linux
.venv/bin/python -m pip install margin-mcp
.venv/bin/margin-mcp --help
# Windows
.venv\Scripts\python.exe -m pip install margin-mcp
.venv\Scripts\margin-mcp.exe --help
No Node.js/npm, database or model server is required for Margin. Connect it to an MCP
host that can launch a local stdio server. The default profile exposes 39 tools;
optional finance, review and review-simple profiles expose focused views.
Connect an MCP host
Merge this entry into your host's MCP server configuration. Replace the executable
path with your installation's absolute path. On Windows use the absolute
.venv\\Scripts\\margin-mcp.exe path with JSON-escaped backslashes.
{
"mcpServers": {
"margin": {
"command": "/absolute/path/.venv/bin/margin-mcp",
"args": ["--mode", "live", "--tool-profile", "all"],
"env": {
"MARGIN_BHARATSTOCK_REQUESTS": "0",
"MARGIN_DRISHTI_REQUESTS": "0",
"MARGIN_DRISHTI_CREDITS": "0"
}
}
}
}
Start with margin_status in the host. This configuration allows local discovery,
explicit-input calculations and supplied-text reviews while making no provider
requests. It does not authenticate provider access. Set explicit remaining process
allowances before authorizing live research; these are not account balances.
Bring your own provider keys
Include only the providers you use in a private file outside the checkout:
BHARATSTOCK_API_KEY=YOUR_BHARATSTOCK_KEY
DRISHTI_API_KEY=YOUR_DRISHTI_KEY
Protect the file using your operating system's access controls. Add these two args to the MCP configuration:
["--credentials-file", "/absolute/private/providers.env"]
Keys can alternatively be passed through the MCP process environment. Margin does not
search for .env files automatically. Provider subscriptions, entitlements and usage
belong to each user. Keep keys out of prompts and tool arguments.
Credential setup and precedence.
What you can do
- Retrieve supported financial, price, news, announcement and earnings records.
- Check company-data readiness and calculate margins, profitability, liquidity, cash-flow metrics, growth, CAGR and eligible quarterly TTM.
- Calculate FCFF, DCF, sensitivities and scenarios from explicit caller inputs.
- Review supplied passages using host judgments, exact quote/reference checks, citation rendering and bounded content-sentiment aggregation.
Results preserve units, periods, reporting basis, scope holds and unknown values. DCF requires explicit forecasts and assumptions. Citation/sentiment judgments come from the host; quote matching does not authenticate an original document or establish market-wide investor sentiment. Provider-filtered records can still be irrelevant.
Margin retains bounded transient state and optional private diagnostic logs. Owner restart loses transient handles and duplicate protection; it does not renew upstream quota. Use stable keys to reconcile lost replies. Functions and limits, review workflows.
Optional local workbench and CLI
python -m pip install "margin-mcp[workbench]"
margin-workbench --mode synthetic
# In another terminal, using the same environment:
margin-agent --expect-mode synthetic status
The workbench serves a local UI/API at http://127.0.0.1:8765. Its synthetic mode uses
labelled fictional data. margin-agent calls that HTTP API; it needs a running
workbench. Activate the virtual environment or use absolute executable paths for
these commands. The workbench is optional; the base MCP installation does not need
FastAPI. The MCP SDK may install server libraries such as uvicorn transitively.
margin-backend is a separate, optional Unix-socket state owner for MCP frontends on
macOS/Linux. Windows uses standalone stdio. Backend/frontend versions must match.
Standalone/shared setup.
The optional host skill is installed separately from the repository; pip does not install or activate skills. CLI and skill guide.
Installation from source
git clone https://github.com/rishitttt/margin-mcp.git
cd margin-mcp
python -m venv .venv
# Use .venv\Scripts\python.exe on Windows.
.venv/bin/python -m pip install .
# Optional UI/API:
.venv/bin/python -m pip install ".[workbench]"
To build and validate release artifacts:
.venv/bin/python -m pip install ".[dev,workbench,release]"
.venv/bin/python -m build
.venv/bin/python -m twine check --strict dist/*
.venv/bin/python scripts/check_distributions.py --version 0.10.1
Use a clean build directory. The sdist contains the self-contained product tests; research/private-bundle tests remain repository-only. Software checks use fictional fixtures and make no live provider requests. Release checks, validation evidence, changelog.
Authors and license
Rishit Anand, Advait Sharma, Arsalaan Alam, Tanvi Sanghai.
Licensed under MIT. Provider data and services remain subject to their own terms.
Metadata
Release files for margin-mcp 0.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| margin_mcp-0.10.1.tar.gz | 223.0 kB | With provenance | Details for margin_mcp-0.10.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| margin_mcp-0.10.1-py3-none-any.whl | Python 3 | none | any | Details for margin_mcp-0.10.1-py3-none-any.whl |
Total release size: 387.2 kB
Release files / margin_mcp-0.10.1.tar.gz
| Download URL | margin_mcp-0.10.1.tar.gz |
|---|---|
| Size | 223.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6ec4798758069964fd692482905b45adefa4242402c695d60fea8632e87f8ad
|
|
BLAKE2b-256 checksum How to use checksums |
cd995102551fec6d5abb10c6a2b55bd82cd01708ff484cf0398968b2789384e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / margin_mcp-0.10.1-py3-none-any.whl
| Download URL | margin_mcp-0.10.1-py3-none-any.whl |
|---|---|
| Size | 164.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d2a59d53be34e124fa9a3556f6bbe93912a426d17e36a2de351fc22c611a6c7
|
|
BLAKE2b-256 checksum How to use checksums |
8544761dbf328b1ab88a335b4d3d67bbf91585bf41c6ca58425ae31cf07a5764
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for margin-mcp 0.10.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for margin_mcp-0.10.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.