server_host.py•2.02 kB
import os
import sys
import asyncio
from fastmcp import FastMCP
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from server.chatbot import Chatbot
from server.helper import get_sec_filing_files
mcp = FastMCP(
name = 'sec-filing-server',
)
@mcp.resource('resource://greeting/')
def get_greeting() -> str:
'''Provides a personalized greeting message'''
return f'Hello! Welcome SEC Filing MCP Chatbot!'
@mcp.resource('resource://companies')
def get_companies() -> list:
'''Returns list of available company tickers'''
return ['AAPL', 'AMZN', 'FL', 'KO', 'META', 'MSFT', 'NVDA', 'TSLA']
@mcp.tool(
name = 'get_sec_files',
description = '''
Gets the SEC filing files for a specific company
Input: company_ticker (str) - The ticker symbol of the company to get SEC filing files for
Output: list of SEC filing files
'''
)
def get_sec_files(company_ticker: str) -> list:
'''
Gets the SEC filing files for a specific company
Input: company_ticker (str) - The ticker symbol of the company to get SEC filing files for
Output: list of SEC filing files
'''
return get_sec_filing_files(company_ticker)
@mcp.tool(
name = 'query_sec',
description = '''
Queries the SEC filings for a specific company
Input: query (str) - The query to search the SEC filings for
Output: str - The response from the SEC filing query
'''
)
def query_sec(query: str) -> str:
'''
Queries the SEC filings for a specific company
Input: query (str) - The query to search the SEC filings for
Output: str - The response from the SEC filing query
'''
return Chatbot().run(query)
if __name__ == '__main__':
try:
print('Starting SEC Filing MCP Chatbot...')
mcp.run(
transport = 'http',
host = '127.0.0.1',
port = 8000,
)
except Exception as e:
print(f'Error: {e}')
sys.exit(1)