# Directory Structure ``` ├── .env.example ├── .gitignore ├── Dockerfile ├── examples │ ├── python-client-example.py │ └── typescript-client-example.ts ├── install.sh ├── LICENSE ├── package-lock.json ├── package.json ├── README.md ├── run-server.sh ├── smithery.yaml ├── src │ └── index.ts └── tsconfig.json ``` # Files -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- ``` 1 | .DS_Store 2 | node_modules 3 | build 4 | .env 5 | dist* ``` -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- ``` 1 | # Octagon API Key 2 | OCTAGON_API_KEY=your_octagon_api_key_here 3 | 4 | # Base URL for Octagon API 5 | OCTAGON_API_BASE_URL=https://api.octagonagents.com/v1 ``` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- ```markdown 1 | # Octagon: MCP for Market Data 2 | 3 | [](https://smithery.ai/server/@OctagonAI/octagon-mcp-server) 4 | 5 |  The Octagon MCP server provides specialized AI-powered financial research and analysis by integrating with the Octagon Market Intelligence API, enabling users to easily analyze and extract detailed insights from public filings, earnings call transcripts, financial metrics, stock market data, and extensive private market transactions within Claude Desktop and other popular MCP clients. 6 | 7 | [](https://docs.octagonagents.com/financial_model_demo.mp4) 8 | 9 | ## Features 10 | 11 | ✅ **Comprehensive Market Intelligence** - Orchestrates multiple specialized agents for complete market analysis 12 | - SEC filings analysis and data extraction (8000+ public companies 10-K, 10-Q, 8-K, 20-F, S-1) 13 | - Earnings call transcript analysis (10 yrs of historical and current) 14 | - Financial metrics and ratios analysis (10 yrs of historical and current) 15 | - Stock market data access (over 10,000 active tickers, daily historical and current) 16 | - Private company research (3M+ companies) 17 | - Funding rounds and venture capital research (500k+ deals) 18 | - M&A and IPO transaction research (2M+ deals) 19 | - Institutional holdings and Form 13F filings 20 | - Cryptocurrency market data and analysis 21 | 22 | ✅ **Deep Research Capabilities** - Comprehensive research tools that can aggregate information from multiple sources 23 | 24 | ✅ **Web Scraping** - Extract structured data from any public website (json, csv, python scripts) 25 | 26 | ## Get Your Octagon API Key 27 | 28 | To use Octagon MCP, you need to: 29 | 30 | 1. Sign up for a free account at [Octagon](https://app.octagonai.co/signup/?redirectToAfterSignup=https://app.octagonai.co/api-keys) 31 | 2. After logging in, from left menu, navigate to **API Keys** 32 | 3. Generate a new API key 33 | 4. Use this API key in your configuration as the `OCTAGON_API_KEY` value 34 | 35 | ## Prerequisites 36 | 37 | Before installing or running Octagon MCP, you need to have `npx` (which comes with Node.js and npm) installed on your system. 38 | 39 | ### Mac (macOS) 40 | 41 | 1. **Install Homebrew** (if you don't have it): 42 | ```bash 43 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 44 | ``` 45 | 2. **Install Node.js (includes npm and npx):** 46 | ```bash 47 | brew install node 48 | ``` 49 | This will install the latest version of Node.js, npm, and npx. 50 | 51 | 3. **Verify installation:** 52 | ```bash 53 | node -v 54 | npm -v 55 | npx -v 56 | ``` 57 | 58 | ### Windows 59 | 60 | 1. **Download the Node.js installer:** 61 | - Go to [https://nodejs.org/](https://nodejs.org/) and download the LTS version for Windows. 62 | 2. **Run the installer** and follow the prompts. This will install Node.js, npm, and npx. 63 | 3. **Verify installation:** 64 | Open Command Prompt and run: 65 | ```cmd 66 | node -v 67 | npm -v 68 | npx -v 69 | ``` 70 | 71 | If you see version numbers for all three, you are ready to proceed with the installation steps below. 72 | 73 | ## Installation 74 | 75 | ### Running on Claude Desktop 76 | 77 | To configure Octagon MCP for Claude Desktop: 78 | 79 | 1. Open Claude Desktop 80 | 2. Go to Settings > Developer > Edit Config 81 | 3. Add the following to your `claude_desktop_config.json` (Replace `your-octagon-api-key` with your Octagon API key): 82 | ```json 83 | { 84 | "mcpServers": { 85 | "octagon-mcp-server": { 86 | "command": "npx", 87 | "args": ["-y", "octagon-mcp@latest"], 88 | "env": { 89 | "OCTAGON_API_KEY": "YOUR_API_KEY_HERE" 90 | } 91 | } 92 | } 93 | } 94 | ``` 95 | 4. Restart Claude for the changes to take effect 96 | 97 | ### Running on Cursor 98 | 99 | Configuring Cursor Desktop 🖥️ 100 | Note: Requires Cursor version 0.45.6+ 101 | 102 | To configure Octagon MCP in Cursor: 103 | 104 | 1. Open Cursor Settings 105 | 2. Go to Features > MCP Servers 106 | 3. Click "+ Add New MCP Server" 107 | 4. Enter the following: 108 | - Name: "octagon-mcp" (or your preferred name) 109 | - Type: "command" 110 | - Command: `env OCTAGON_API_KEY=your-octagon-api-key npx -y octagon-mcp` 111 | 112 | > If you are using Windows and are running into issues, try `cmd /c "set OCTAGON_API_KEY=your-octagon-api-key && npx -y octagon-mcp"` 113 | 114 | Replace `your-octagon-api-key` with your Octagon API key. 115 | 116 | After adding, refresh the MCP server list to see the new tools. The Composer Agent will automatically use Octagon MCP when appropriate, but you can explicitly request it by describing your investment research needs. Access the Composer via Command+L (Mac), select "Agent" next to the submit button, and enter your query. 117 | 118 | ### Running on Windsurf 119 | 120 | Add this to your `./codeium/windsurf/model_config.json`: 121 | 122 | ```json 123 | { 124 | "mcpServers": { 125 | "octagon-mcp-server": { 126 | "command": "npx", 127 | "args": ["-y", "octagon-mcp@latest"], 128 | "env": { 129 | "OCTAGON_API_KEY": "YOUR_API_KEY_HERE" 130 | } 131 | } 132 | } 133 | } 134 | ``` 135 | 136 | ### Running with npx 137 | 138 | ```bash 139 | env OCTAGON_API_KEY=your_octagon_api_key npx -y octagon-mcp 140 | ``` 141 | 142 | ### Manual Installation 143 | 144 | ```bash 145 | npm install -g octagon-mcp 146 | ``` 147 | 148 | ## Documentation 149 | 150 | For comprehensive documentation on using Octagon agents, please visit our official documentation at: 151 | [https://docs.octagonagents.com](https://docs.octagonagents.com) 152 | 153 | The documentation includes: 154 | - Detailed API references 155 | - Agent-specific query guidelines 156 | - Examples and use cases 157 | - Best practices for investment research 158 | 159 | ## Available Tools 160 | 161 | Each tool uses a single `prompt` parameter that accepts a natural language query. Include all relevant details in your prompt. 162 | 163 | ### octagon-agent 164 | **[COMPREHENSIVE MARKET INTELLIGENCE]** Orchestrates all agents for comprehensive market intelligence analysis. Combines insights from SEC filings, earnings calls, financial metrics, stock data, institutional holdings, private company research, funding analysis, M&A transactions, investor intelligence, and debt analysis. 165 | 166 | **Best for:** Complex research requiring multiple data sources and comprehensive analysis across public and private markets. 167 | 168 | **Example queries:** 169 | ``` 170 | Retrieve year-over-year growth in key income-statement items for AAPL, limited to 5 records and filtered by period FY 171 | Analyze the latest 10-K filing for AAPL and extract key financial metrics and risk factors 172 | Retrieve the daily closing prices for AAPL over the last 30 days 173 | Analyze AAPL's latest earnings call transcript and extract key insights about future guidance 174 | Provide a comprehensive overview of Stripe, including its business model and key metrics 175 | Retrieve the funding history for Stripe, including all rounds and investors 176 | Compare the financial performance of Tesla, Ford, and GM over the last 3 years 177 | What was Microsoft's acquisition of GitHub valued at and what were the strategic reasons? 178 | Analyze institutional ownership changes for NVIDIA over the past 6 months 179 | ``` 180 | 181 | ### octagon-scraper-agent 182 | **[PUBLIC & PRIVATE MARKET INTELLIGENCE]** Specialized agent for financial data extraction from investor websites. Extract structured financial data from investor relations websites, tables, and online financial sources. 183 | 184 | **Best for:** Gathering financial data from websites that don't have accessible APIs. 185 | 186 | **Example queries:** 187 | ``` 188 | Extract all data fields from zillow.com/san-francisco-ca/ 189 | Extract all data fields from www.carvana.com/cars/ 190 | Extract financial metrics from tesla.com/investor-relations 191 | Extract pricing data from salesforce.com/products/platform/pricing/ 192 | ``` 193 | 194 | ### octagon-deep-research-agent 195 | **[PUBLIC & PRIVATE MARKET INTELLIGENCE]** A comprehensive agent that can utilize multiple sources for deep research analysis. Aggregate research across multiple data sources, synthesize information, and provide comprehensive investment research. 196 | 197 | **Best for:** Investment research questions requiring up-to-date aggregated information from the web. 198 | 199 | **Example queries:** 200 | ``` 201 | Research the financial impact of Apple's privacy changes on digital advertising companies' revenue and margins 202 | Analyze the competitive landscape in the cloud computing sector, focusing on AWS, Azure, and Google Cloud margin and growth trends 203 | Investigate the factors driving electric vehicle adoption and their impact on battery supplier financials 204 | Research the impact of AI adoption on semiconductor demand and pricing trends 205 | Analyze the regulatory environment for cryptocurrency and its impact on crypto exchange valuations 206 | ``` 207 | 208 | ## Example Queries 209 | 210 | 1. "What were Amazon's revenue and net income figures in Q4 2023?" 211 | 2. "Analyze Tesla's R&D spending trends over the last 3 years." 212 | 3. "What guidance did NVIDIA's CEO provide regarding AI chip demand in their latest earnings call?" 213 | 4. "Compare the price-to-earnings, price-to-sales, and EV/EBITDA ratios for the top 5 semiconductor companies." 214 | 5. "What was Anthropic's latest funding round size, valuation, and key investors?" 215 | 6. "Extract all data fields from zillow.com/san-francisco-ca/" 216 | 7. "Research the financial impact of Apple's privacy changes on digital advertising companies' revenue and margins" 217 | 8. "How many investments did Andreessen Horowitz make in AI startups in the last 12 months?" 218 | 9. "Retrieve historical Bitcoin price data from 2023 and analyze the price volatility trends" 219 | 10. "Analyze the competitive dynamics in the EV charging infrastructure market" 220 | 221 | ## Troubleshooting 222 | 223 | 1. **API Key Issues**: Ensure your Octagon API key is correctly set in the environment or config file. 224 | 2. **Connection Issues**: Make sure the connectivity to the Octagon API is working properly. 225 | 3. **Rate Limiting**: If you encounter rate limiting errors, reduce the frequency of your requests. 226 | 227 | ## License 228 | 229 | MIT 230 | 231 | ## Individual Specialized MCP Servers 232 | 233 | While this server provides comprehensive market intelligence combining all our specialized agents, you can also use our individual MCP servers for specific use cases: 234 | 235 | ### Public Market Data Servers 236 | - **[Octagon SEC Filings MCP](https://github.com/OctagonAI/octagon-sec-filings-mcp)** - Dedicated server for SEC filings analysis 237 | - **[Octagon Earnings Transcripts MCP](https://github.com/OctagonAI/octagon-earnings-transcripts-mcp)** - Specialized for earnings call transcript analysis 238 | - **[Octagon Stock Market Data MCP](https://github.com/OctagonAI/octagon-stock-market-data-mcp)** - Focused on stock market data access 239 | - **[Octagon Financial Statements MCP](https://github.com/OctagonAI/octagon-financial-statements-mcp)** - Financial metrics and ratios analysis 240 | - **[Octagon 13F Holdings MCP](https://github.com/OctagonAI/octagon-13f-holdings-mcp)** - Institutional ownership and Form 13F filings 241 | 242 | ### Private Market Data Servers 243 | - **[Octagon Private Companies MCP](https://github.com/OctagonAI/octagon-private-companies-mcp)** - Private company research and intelligence 244 | - **[Octagon Investors MCP](https://github.com/OctagonAI/octagon-investors-mcp)** - Investor profiles and investment strategies 245 | - **[Octagon Funding Data MCP](https://github.com/OctagonAI/octagon-funding-data-mcp)** - Startup funding rounds and venture capital data 246 | 247 | ### Research Tools 248 | - **[Octagon Deep Research MCP](https://github.com/OctagonAI/octagon-deep-research-mcp)** - Comprehensive research and web scraping capabilities 249 | 250 | --- 251 | 252 | ⭐ Star this repo if you find it helpful! 253 | ``` -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- ```dockerfile 1 | FROM node:18-alpine 2 | 3 | WORKDIR /app 4 | 5 | # Copy package files 6 | COPY package*.json ./ 7 | 8 | # Install dependencies 9 | RUN npm install --ignore-scripts 10 | 11 | # Copy source code 12 | COPY . . 13 | 14 | # Build the application 15 | RUN npm run build 16 | 17 | # Run the server 18 | CMD ["node", "dist/index.js"] ``` -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "forceConsistentCasingInFileNames": true 12 | }, 13 | "include": ["src/**/*"], 14 | "exclude": ["node_modules", "dist", "examples"] 15 | } ``` -------------------------------------------------------------------------------- /smithery.yaml: -------------------------------------------------------------------------------- ```yaml 1 | startCommand: 2 | type: stdio 3 | configSchema: 4 | type: object 5 | required: 6 | - octagonApiKey 7 | properties: 8 | octagonApiKey: 9 | type: string 10 | description: Your Octagon API key (get a free one at https://app.octagonai.co/signup) 11 | commandFunction: | 12 | (config) => ({ 13 | command: 'node', 14 | args: ['dist/index.js'], 15 | env: { OCTAGON_API_KEY: config.octagonApiKey } 16 | }) ``` -------------------------------------------------------------------------------- /run-server.sh: -------------------------------------------------------------------------------- ```bash 1 | #!/bin/bash 2 | 3 | # Octagon MCP Server Run Script 4 | 5 | echo "Starting Octagon MCP Server..." 6 | 7 | # Check if the dist directory exists, if not, build the project 8 | if [ ! -d "./dist" ]; then 9 | echo "Dist directory not found. Building project..." 10 | npm run build 11 | fi 12 | 13 | # Check if OCTAGON_API_KEY is set 14 | if [ -z "$OCTAGON_API_KEY" ]; then 15 | # Try to load from .env file 16 | if [ -f ".env" ]; then 17 | export $(grep -v '^#' .env | xargs) 18 | fi 19 | 20 | # Check again if OCTAGON_API_KEY is set 21 | if [ -z "$OCTAGON_API_KEY" ]; then 22 | echo "Error: OCTAGON_API_KEY environment variable not set." 23 | echo "Please set your API key using: export OCTAGON_API_KEY=your_api_key" 24 | echo "Or create a .env file with OCTAGON_API_KEY=your_api_key" 25 | exit 1 26 | fi 27 | fi 28 | 29 | # Run the server 30 | echo "Running server..." 31 | node dist/index.js ``` -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "name": "octagon-mcp", 3 | "version": "1.0.22", 4 | "description": "MCP server for Octagon API. Provides specialized AI agents for investment research of public and private markets.", 5 | "main": "dist/index.js", 6 | "type": "module", 7 | "bin": { 8 | "octagon-mcp": "dist/index.js" 9 | }, 10 | "files": [ 11 | "dist" 12 | ], 13 | "publishConfig": { 14 | "access": "public" 15 | }, 16 | "scripts": { 17 | "build": "tsc && node -e \"require('fs').chmodSync('dist/index.js', '755')\"", 18 | "test": "echo \"No tests specified\"", 19 | "start": "node dist/index.js", 20 | "lint": "echo \"No linting configured\"", 21 | "format": "echo \"No formatting configured\"", 22 | "prepare": "npm run build", 23 | "release": "npm run build && npm publish" 24 | }, 25 | "keywords": [ 26 | "mcp", 27 | "octagon", 28 | "investment-research", 29 | "sec-filings", 30 | "earnings-transcripts", 31 | "financial-data", 32 | "market-data", 33 | "private-company-research" 34 | ], 35 | "author": "Octagon AI", 36 | "license": "MIT", 37 | "dependencies": { 38 | "@modelcontextprotocol/sdk": "^1.0.0", 39 | "dotenv": "^16.3.1", 40 | "openai": "^4.20.1", 41 | "zod": "^3.22.4" 42 | }, 43 | "devDependencies": { 44 | "@types/node": "^20.10.0", 45 | "ts-node": "^10.9.2", 46 | "typescript": "^5.3.2" 47 | }, 48 | "engines": { 49 | "node": ">=18.0.0" 50 | }, 51 | "repository": { 52 | "type": "git", 53 | "url": "git+https://github.com/OctagonAI/octagon-mcp-server.git" 54 | }, 55 | "bugs": { 56 | "url": "https://github.com/OctagonAI/octagon-mcp-server/issues" 57 | }, 58 | "homepage": "https://docs.octagonagents.com" 59 | } 60 | ``` -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- ```bash 1 | #!/bin/bash 2 | 3 | # Octagon MCP Server Installation Script 4 | 5 | echo "Installing Octagon MCP Server..." 6 | 7 | # Check if Node.js is installed 8 | if ! command -v node &> /dev/null; then 9 | echo "Node.js is not installed. Please install Node.js before continuing." 10 | exit 1 11 | fi 12 | 13 | # Check if npm is installed 14 | if ! command -v npm &> /dev/null; then 15 | echo "npm is not installed. Please install npm before continuing." 16 | exit 1 17 | fi 18 | 19 | # Install dependencies 20 | echo "Installing dependencies..." 21 | npm install 22 | 23 | # Build the server 24 | echo "Building the server..." 25 | npm run build 26 | 27 | # Create .env file if it doesn't exist 28 | if [ ! -f .env ]; then 29 | echo "Creating .env file..." 30 | cp .env.example .env 31 | echo "Please edit the .env file and add your Octagon API key." 32 | fi 33 | 34 | echo "Installation complete!" 35 | echo "" 36 | echo "There are multiple ways to use the Octagon MCP Server:" 37 | echo "" 38 | echo "1. Run directly with your API key:" 39 | echo " env OCTAGON_API_KEY=your_octagon_api_key node ./dist/index.js" 40 | echo "" 41 | echo "2. Install globally and run with npx:" 42 | echo " npm install -g ." 43 | echo " env OCTAGON_API_KEY=your_octagon_api_key npx octagon-mcp" 44 | echo "" 45 | echo "3. To use with Claude Desktop, add the following to your claude_desktop_config.json:" 46 | echo '{ 47 | "mcpServers": { 48 | "octagon": { 49 | "command": "env", 50 | "args": ["OCTAGON_API_KEY=your_octagon_api_key", "npx", "-y", "octagon-mcp"] 51 | } 52 | } 53 | }' 54 | echo "" 55 | echo "4. To use with Cursor, add a new MCP server with:" 56 | echo " - Name: octagon-mcp" 57 | echo " - Type: command" 58 | echo " - Command: env OCTAGON_API_KEY=your_octagon_api_key npx -y octagon-mcp" ``` -------------------------------------------------------------------------------- /examples/typescript-client-example.ts: -------------------------------------------------------------------------------- ```typescript 1 | import { Client } from "@modelcontextprotocol/sdk/client/index.js"; 2 | import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; 3 | 4 | async function main() { 5 | try { 6 | // Create a client 7 | const client = new Client({ 8 | name: "octagon-client-example", 9 | version: "1.0.0", 10 | }); 11 | 12 | // Connect to the server 13 | const transport = new StdioClientTransport({ 14 | command: "node", 15 | args: ["../build/index.js"], // Updated path to reflect the new location 16 | }); 17 | await client.connect(transport); 18 | 19 | console.log("Connected to Octagon MCP server"); 20 | 21 | // List available tools 22 | const toolsResult = await client.listTools(); 23 | console.log("Available tools:"); 24 | for (const tool of toolsResult.tools) { 25 | console.log(`- ${tool.name}: ${tool.description}`); 26 | } 27 | 28 | // Example: Query comprehensive market intelligence 29 | console.log("\nQuerying comprehensive market intelligence for Apple..."); 30 | const marketResult = await client.callTool({ 31 | name: "octagon-agent", 32 | arguments: { 33 | prompt: "Analyze Apple's latest 10-K filing and extract key financial metrics and risk factors", 34 | }, 35 | }); 36 | 37 | console.log("Market Intelligence Result:"); 38 | console.log((marketResult as any).content[0].text); 39 | 40 | // Example: Deep research analysis 41 | console.log("\nPerforming deep research on AI market trends..."); 42 | const researchResult = await client.callTool({ 43 | name: "octagon-deep-research-agent", 44 | arguments: { 45 | prompt: "Research the financial impact of AI adoption on semiconductor companies' revenue and margins", 46 | }, 47 | }); 48 | 49 | console.log("Deep Research Analysis:"); 50 | console.log((researchResult as any).content[0].text); 51 | 52 | // Example: Web scraping 53 | console.log("\nExtracting data from a website..."); 54 | const scrapingResult = await client.callTool({ 55 | name: "octagon-scraper-agent", 56 | arguments: { 57 | prompt: "Extract all data fields from zillow.com/san-francisco-ca/", 58 | }, 59 | }); 60 | 61 | console.log("Web Scraping Result:"); 62 | console.log((scrapingResult as any).content[0].text); 63 | 64 | // Close the client 65 | await client.close(); 66 | } catch (error) { 67 | console.error("Error:", error); 68 | process.exit(1); 69 | } 70 | } 71 | 72 | main(); ``` -------------------------------------------------------------------------------- /examples/python-client-example.py: -------------------------------------------------------------------------------- ```python 1 | #!/usr/bin/env python3 2 | import asyncio 3 | import os 4 | from typing import Optional 5 | from mcp import ClientSession, StdioServerParameters 6 | from mcp.client.stdio import stdio_client 7 | 8 | async def main(): 9 | # Create server parameters for stdio connection 10 | server_params = StdioServerParameters( 11 | command="node", 12 | args=["../build/index.js"], # Updated path to reflect the new location 13 | env=None 14 | ) 15 | 16 | # Connect to the server 17 | async with stdio_client(server_params) as (read, write): 18 | async with ClientSession(read, write) as session: 19 | # Initialize the connection 20 | await session.initialize() 21 | print("Connected to Octagon MCP server") 22 | 23 | # List available tools 24 | tools = await session.list_tools() 25 | print("Available tools:") 26 | for tool in tools.tools: 27 | print(f"- {tool.name}: {tool.description}") 28 | 29 | # Example: Query comprehensive market intelligence 30 | print("\nQuerying comprehensive market intelligence for Apple...") 31 | market_result = await session.call_tool( 32 | "octagon-agent", 33 | arguments={ 34 | "prompt": "Analyze Apple's latest 10-K filing and extract key financial metrics and risk factors" 35 | } 36 | ) 37 | print("Market Intelligence Result:") 38 | print(market_result.content[0].text) 39 | 40 | # Example: Deep research analysis 41 | print("\nPerforming deep research on AI market trends...") 42 | research_result = await session.call_tool( 43 | "octagon-deep-research-agent", 44 | arguments={ 45 | "prompt": "Research the financial impact of AI adoption on semiconductor companies' revenue and margins" 46 | } 47 | ) 48 | print("Deep Research Analysis:") 49 | print(research_result.content[0].text) 50 | 51 | # Example: Web scraping 52 | print("\nExtracting data from a website...") 53 | scraping_result = await session.call_tool( 54 | "octagon-scraper-agent", 55 | arguments={ 56 | "prompt": "Extract all data fields from zillow.com/san-francisco-ca/" 57 | } 58 | ) 59 | print("Web Scraping Result:") 60 | print(scraping_result.content[0].text) 61 | 62 | if __name__ == "__main__": 63 | asyncio.run(main()) ``` -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- ```typescript 1 | #!/usr/bin/env node 2 | 3 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 4 | import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; 5 | import dotenv from "dotenv"; 6 | import { readFile } from "fs/promises"; 7 | import OpenAI from "openai"; 8 | import path from "path"; 9 | import { fileURLToPath } from "url"; 10 | import { z } from "zod"; 11 | 12 | // Get package.json info 13 | const __filename = fileURLToPath(import.meta.url); 14 | const __dirname = path.dirname(__filename); 15 | const packageJsonPath = path.join(__dirname, "..", "package.json"); 16 | const packageJsonContent = await readFile(packageJsonPath, "utf8"); 17 | const packageInfo = JSON.parse(packageJsonContent) as { name: string; version: string }; 18 | 19 | // Load environment variables 20 | dotenv.config(); 21 | 22 | // Check for required environment variables 23 | const OCTAGON_API_KEY = process.env.OCTAGON_API_KEY; 24 | const OCTAGON_API_BASE_URL = process.env.OCTAGON_API_BASE_URL || "https://api.octagonagents.com/v1"; 25 | 26 | if (!OCTAGON_API_KEY) { 27 | console.error("Error: OCTAGON_API_KEY is not set in the environment variables"); 28 | console.error("Please set the OCTAGON_API_KEY environment variable or use 'env OCTAGON_API_KEY=your_key npx -y octagon-mcp'"); 29 | process.exit(1); 30 | } 31 | 32 | // Initialize OpenAI client with Octagon API 33 | const octagonClient = new OpenAI({ 34 | apiKey: OCTAGON_API_KEY, 35 | baseURL: OCTAGON_API_BASE_URL, 36 | defaultHeaders: { 37 | "User-Agent": `${packageInfo.name}/${packageInfo.version} (Node.js/${process.versions.node})` 38 | }, 39 | }); 40 | 41 | // Create MCP server 42 | const server = new McpServer({ 43 | name: packageInfo.name, 44 | version: packageInfo.version, 45 | }); 46 | 47 | // Helper function to process streaming responses 48 | async function processStreamingResponse(stream: any): Promise<string> { 49 | let fullResponse = ""; 50 | let citations: any[] = []; 51 | 52 | try { 53 | // Process the streaming response 54 | for await (const chunk of stream) { 55 | // For Chat Completions API 56 | if (chunk.choices && chunk.choices[0]?.delta?.content) { 57 | fullResponse += chunk.choices[0].delta.content; 58 | 59 | // Check for citations in the final chunk 60 | if (chunk.choices[0]?.finish_reason === "stop" && chunk.choices[0]?.citations) { 61 | citations = chunk.choices[0].citations; 62 | } 63 | } 64 | 65 | // For Responses API 66 | if (chunk.type === "response.output_text.delta") { 67 | fullResponse += chunk.text?.delta || ""; 68 | } 69 | } 70 | 71 | return fullResponse; 72 | } catch (error) { 73 | console.error("Error processing streaming response:", error); 74 | throw error; 75 | } 76 | } 77 | 78 | // Define a schema for the 'prompt' parameter that all tools will use 79 | const promptSchema = z.object({ 80 | prompt: z.string().describe("Your natural language query or request for the agent"), 81 | }); 82 | 83 | type PromptParams = { 84 | prompt: string; 85 | }; 86 | 87 | // Comprehensive Orchestration Agent 88 | server.tool( 89 | "octagon-agent", 90 | "[COMPREHENSIVE MARKET INTELLIGENCE] Orchestrates all agents for comprehensive market intelligence analysis. Capabilities: Combines insights from SEC filings, earnings calls, financial metrics, stock data, institutional holdings, private company research, funding analysis, M&A transactions, investor intelligence, and debt analysis to provide holistic market intelligence. Best for: Complex research requiring multiple data sources and comprehensive analysis across public and private markets. Example queries: 'Retrieve year-over-year growth in key income-statement items for AAPL, limited to 5 records and filtered by period FY', 'Analyze the latest 10-K filing for AAPL and extract key financial metrics and risk factors', 'Retrieve the daily closing prices for AAPL over the last 30 days', 'Analyze AAPL's latest earnings call transcript and extract key insights about future guidance', 'Provide a comprehensive overview of Stripe, including its business model and key metrics', 'Retrieve the funding history for Stripe, including all rounds and investors'.", 91 | { 92 | prompt: z.string().describe("Your natural language query or request for the agent"), 93 | }, 94 | async ({ prompt }: PromptParams) => { 95 | try { 96 | const response = await octagonClient.chat.completions.create({ 97 | model: "octagon-agent", 98 | messages: [{ role: "user", content: prompt }], 99 | stream: true, 100 | metadata: { tool: "mcp" } 101 | }); 102 | 103 | const result = await processStreamingResponse(response); 104 | return { 105 | content: [ 106 | { 107 | type: "text", 108 | text: result, 109 | }, 110 | ], 111 | }; 112 | } catch (error) { 113 | console.error("Error calling Octagon orchestration agent:", error); 114 | return { 115 | isError: true, 116 | content: [ 117 | { 118 | type: "text", 119 | text: `Error: Failed to process comprehensive market intelligence query. ${error}`, 120 | }, 121 | ], 122 | }; 123 | } 124 | } 125 | ); 126 | 127 | // Web Scraper Agent 128 | server.tool( 129 | "octagon-scraper-agent", 130 | "[PUBLIC & PRIVATE MARKET INTELLIGENCE] Specialized agent for financial data extraction from investor websites. Capabilities: Extract structured financial data from investor relations websites, tables, and online financial sources. Best for: Gathering financial data from websites that don't have accessible APIs. Example queries: 'Extract all data fields from zillow.com/san-francisco-ca/', 'Extract all data fields from www.carvana.com/cars/'.", 131 | { 132 | prompt: z.string().describe("Your natural language query or request for the agent"), 133 | }, 134 | async ({ prompt }: PromptParams) => { 135 | try { 136 | const response = await octagonClient.chat.completions.create({ 137 | model: "octagon-scraper-agent", 138 | messages: [{ role: "user", content: prompt }], 139 | stream: true, 140 | metadata: { tool: "mcp" } 141 | }); 142 | 143 | const result = await processStreamingResponse(response); 144 | return { 145 | content: [ 146 | { 147 | type: "text", 148 | text: result, 149 | }, 150 | ], 151 | }; 152 | } catch (error) { 153 | console.error("Error calling Scraper agent:", error); 154 | return { 155 | isError: true, 156 | content: [ 157 | { 158 | type: "text", 159 | text: `Error: Failed to process web scraping query. ${error}`, 160 | }, 161 | ], 162 | }; 163 | } 164 | } 165 | ); 166 | 167 | // Deep Research Agent 168 | server.tool( 169 | "octagon-deep-research-agent", 170 | "[PUBLIC & PRIVATE MARKET INTELLIGENCE] A comprehensive agent that can utilize multiple sources for deep research analysis. Capabilities: Aggregate research across multiple data sources, synthesize information, and provide comprehensive investment research. Best for: Investment research questions requiring up-to-date aggregated information from the web. Example queries: 'Research the financial impact of Apple's privacy changes on digital advertising companies' revenue and margins', 'Analyze the competitive landscape in the cloud computing sector, focusing on AWS, Azure, and Google Cloud margin and growth trends', 'Investigate the factors driving electric vehicle adoption and their impact on battery supplier financials'.", 171 | { 172 | prompt: z.string().describe("Your natural language query or request for the agent"), 173 | }, 174 | async ({ prompt }: PromptParams) => { 175 | try { 176 | const response = await octagonClient.chat.completions.create({ 177 | model: "octagon-deep-research-agent", 178 | messages: [{ role: "user", content: prompt }], 179 | stream: true, 180 | metadata: { tool: "mcp" } 181 | }); 182 | 183 | const result = await processStreamingResponse(response); 184 | return { 185 | content: [ 186 | { 187 | type: "text", 188 | text: result, 189 | }, 190 | ], 191 | }; 192 | } catch (error) { 193 | console.error("Error calling Deep Research agent:", error); 194 | return { 195 | isError: true, 196 | content: [ 197 | { 198 | type: "text", 199 | text: `Error: Failed to process deep research query. ${error}`, 200 | }, 201 | ], 202 | }; 203 | } 204 | } 205 | ); 206 | 207 | // Start the server with stdio transport 208 | async function main() { 209 | try { 210 | const transport = new StdioServerTransport(); 211 | await server.connect(transport); 212 | } catch (error) { 213 | process.exit(1); 214 | } 215 | } 216 | 217 | main(); 218 | ```