Investment MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Investment MCP Serverget research snapshot for AAPL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
# Investment MCP Server
Private, authenticated MCP server for your SQL Server investment database.
It exposes read-only tools over:
dbo.Seriesdbo.SeriesDatadbo.TradeGetDaysChangeReturn
The server does not expose a raw SQL tool. All database access is parameterized. Private portfolio tools derive the caller from the bearer token and scope every account query to that authenticated user.
Install
cd "C:\Users\asmir\source\repos\investment_mcp"
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
copy .env.example .envEdit .env with your SQL Server name and database name.
Related MCP server: yahoo-finance-mcp
SQL Permissions
Use a read-only SQL login/user if possible:
CREATE LOGIN mcp_investments_login WITH PASSWORD = 'replace-with-strong-password';
CREATE USER mcp_investments_user FOR LOGIN mcp_investments_login;
GRANT SELECT ON dbo.Series TO mcp_investments_user;
GRANT SELECT ON dbo.SeriesData TO mcp_investments_user;
GRANT EXECUTE ON dbo.TradeGetDaysChangeReturn TO mcp_investments_user;If you use Windows authentication instead, grant the same permissions to your Windows user.
Run Locally
.\.venv\Scripts\Activate.ps1
python server.pyWith MCP_TRANSPORT=stdio, the command starts silently and waits for an MCP client. A blank terminal is expected. Press Ctrl+C to stop it.
For MCP Inspector:
mcp dev server.pyCodex MCP Config Example
Add something like this to your Codex MCP config, adjusting paths and connection string:
[mcp_servers.investments]
command = "C:\\Users\\asmir\\source\\repos\\investment_mcp\\.venv\\Scripts\\python.exe"
args = ["C:\\Users\\asmir\\source\\repos\\investment_mcp\\server.py"]
env = { SQLSERVER_CONN = "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost;DATABASE=Investments;Trusted_Connection=yes;Encrypt=yes;TrustServerCertificate=yes;" }Tools
search_symbolsget_symbol_profileget_latest_pricesget_price_historyget_research_snapshotcompare_symbolsscreen_instrumentsget_watched_symbolsget_traded_symbolsget_data_freshnessget_market_indicators
Caller-scoped portfolio tools:
get_my_accountsget_my_portfolioget_my_open_ordersrecord_trade_executioncreate_limit_order_recordupdate_limit_order_recordcancel_limit_order_recordupdate_cash_balanceget_my_strategyupdate_my_strategy
Explicit sharing tools:
share_portfoliorevoke_portfolio_accesslist_portfolio_accessget_shared_portfolios
Write tools require UUID idempotency keys. Concurrent updates use SQL Server
rowversion values returned as hexadecimal strings.
Limit-order create and update tools accept optional duration and expires_on
fields. duration accepts DAY, GTC, GTD, IOC, or FOK (including common
long-form aliases), and expires_on uses YYYY-MM-DD. For example, an order
good through October 2, 2026 uses duration="GTD" and
expires_on="2026-10-02".
Private schema migrations
Run these in order against the investment database:
sql/001_create_invest_schema.sqlsql/002_add_private_tool_safety.sqlsql/003_grant_mcp_connector_runtime.sqlsql/004_add_database_api_tokens.sqlsql/005_add_order_duration_expiration.sql
The second migration adds idempotency records, order status history, the
(UserId, AccountId, ClientOrderId) uniqueness rule, and soft-deletion fields.
Database-backed bearer identity
Each user can have multiple independently revocable tokens. SQL Server stores
only a SHA-256 digest of each cryptographically random 256-bit token. The MCP
runtime cannot read token hashes or issue tokens; it can only execute
invest.AuthenticateApiToken.
Issue a token from an administrator connection in SSMS:
EXEC invest.IssueApiToken
@AuthenticationSubject = N'local:andreySr',
@TokenName = N'Andrey Codex desktop',
@ExpiresAt = '2027-08-10T00:00:00-04:00';Copy PlaintextToken from the result immediately. It is returned only once and
must be delivered to the user through a secure channel. Configure the hosted
service with:
MCP_TOKEN_AUTH_MODE=databaseThe user's Codex configuration continues to reference an environment variable:
[mcp_servers.investments]
url = "https://investments-mcp.torusystems.com/mcp"
bearer_token_env_var = "INVESTMENTS_MCP_TOKEN"
startup_timeout_sec = 30
tool_timeout_sec = 120Set INVESTMENTS_MCP_TOKEN to the issued plaintext token on that user's
computer. Never store plaintext tokens in SQL Server, GitHub, logs, or support
messages.
List or revoke tokens from an administrator connection:
EXEC invest.ListApiTokens
@AuthenticationSubject = N'local:andreySr';
EXEC invest.RevokeApiToken
@AuthenticationSubject = N'local:andreySr',
@ApiTokenId = '00000000-0000-0000-0000-000000000000';Safe migration from environment tokens
Run migration
004and issue a new database token.Set
MCP_TOKEN_AUTH_MODE=hybrid, retaining the old token variables.Deploy and restart the service. Both old and database tokens work.
Move every client to its new database token and verify caller isolation.
Set
MCP_TOKEN_AUTH_MODE=database, deleteMCP_BEARER_TOKEN,MCP_DEFAULT_AUTH_SUBJECT, andMCP_TOKEN_SUBJECTS_JSON, then restart.
A future website should authenticate the human user, enforce subscription or entitlement rules separately from the token table, and call the issue/list/revoke procedures through a separate least-privilege database principal. The MCP runtime database principal must never receive token-administration permissions. For a public self-service integration, plan to add MCP-standard OAuth 2.1 rather than making permanent API keys the only login method.
The research tools call dbo.TradeGetDaysChangeReturn by default. If that procedure returns a large result set, create the optional filtered wrapper in sql/create_mcp_research_sp.sql and set:
MCP_RESEARCH_PROCEDURE=dbo.McpGetResearch
MCP_RESEARCH_PROCEDURE_HAS_FILTERS=trueImportant
The order tools record portfolio state only. They do not submit orders to a brokerage. Codex approval prompts are supplemental protection; authorization is always enforced by this server.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceProvides database interaction and business intelligence capabilities, enabling users to run SQL queries, analyze business data, and automatically generate business insight memos for Microsoft SQL Server databases.39MIT
- AlicenseAqualityCmaintenanceProvides access to Yahoo Finance data including real-time stock quotes, historical prices, financial statements, company info, symbol search, and news.6591MIT
- Flicense-qualityDmaintenanceProvides secure, read-only access to Microsoft SQL Server with multi-layer protection, enabling safe query execution, schema discovery, and SQL script analysis through natural language.1
- Flicense-qualityDmaintenanceEnables secure interaction with Microsoft SQL Server databases, allowing schema exploration, metadata retrieval, and read-only query execution through natural language.1
Related MCP Connectors
The stock market, in SQL — scan, replay, or subscribe across ~12k US tickers and top 100 cryptos.
Access SEC filings, insider transactions, and financial data via the ShareSEER API.
Search SEC filings, read 10-K/8-K, query XBRL facts, track Form 4 insider trades.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/smiryagin/investment_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server