Skip to main content
Glama
Juuuuuuni

Stock MCP Server

by Juuuuuuni

get_us_stock_analysis

Analyze US stock data with technical indicators by providing a ticker symbol and optional analysis period. Evaluate trends and momentum using parameters for symbol and days.

Instructions

미국 주식 종목을 분석합니다.

Args: symbol: 티커 심볼 (예: 'AAPL', 'TSLA', 'NVDA', 'GOOGL') days: 조회 기간 (일수, 기본 120일)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
daysNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'get_us_stock_analysis' - fetches US stock data via yfinance, computes technical indicators (SMA, RSI, MACD, Bollinger Bands, Ichimoku), and returns analysis as JSON.
    def get_us_stock_analysis(symbol: str, days: int = 120) -> str:
        """미국 주식 종목을 분석합니다.
    
        Args:
            symbol: 티커 심볼 (예: 'AAPL', 'TSLA', 'NVDA', 'GOOGL')
            days: 조회 기간 (일수, 기본 120일)
        """
        tk = yf.Ticker(symbol)
        df = tk.history(period=f"{days}d")
    
        if df.empty:
            return f"'{symbol}'에 대한 데이터를 찾을 수 없습니다."
        if len(df) < 2:
            return f"'{symbol}'의 데이터가 부족합니다 (거래일 {len(df)}일). 분석 기간을 늘려주세요."
    
        info = tk.info
        name = info.get("shortName", symbol)
    
        # 기술적 지표 계산
        df['SMA5'] = df['Close'].rolling(5).mean()
        df['SMA20'] = df['Close'].rolling(20).mean()
        df['SMA60'] = df['Close'].rolling(60).mean()
        df['RSI'] = ta.momentum.RSIIndicator(df['Close'], window=14).rsi()
    
        macd_ind = ta.trend.MACD(df['Close'])
        df['MACD'] = macd_ind.macd()
        df['MACD_signal'] = macd_ind.macd_signal()
        df['MACD_hist'] = macd_ind.macd_diff()
    
        bb = ta.volatility.BollingerBands(df['Close'])
        df['BB_upper'] = bb.bollinger_hband()
        df['BB_lower'] = bb.bollinger_lband()
    
        ichimoku = ta.trend.IchimokuIndicator(df['High'], df['Low'], window1=9, window2=26, window3=52)
        df['Ichimoku_conversion'] = ichimoku.ichimoku_conversion_line()
        df['Ichimoku_base'] = ichimoku.ichimoku_base_line()
        df['Ichimoku_span_a'] = ichimoku.ichimoku_a()
        df['Ichimoku_span_b'] = ichimoku.ichimoku_b()
        df['Ichimoku_lagging'] = df['Close'].shift(-26)
    
        latest = df.iloc[-1]
        prev = df.iloc[-2]
    
        result = {
            "종목명": name,
            "심볼": symbol,
            "현재가": round(latest['Close'], 2),
            "전일대비": round(latest['Close'] - prev['Close'], 2),
            "등락률": round((latest['Close'] - prev['Close']) / prev['Close'] * 100, 2),
            "거래량": int(latest['Volume']),
            "기술적지표": {
                "SMA5": round(latest['SMA5'], 2) if pd.notna(latest['SMA5']) else None,
                "SMA20": round(latest['SMA20'], 2) if pd.notna(latest['SMA20']) else None,
                "SMA60": round(latest['SMA60'], 2) if pd.notna(latest['SMA60']) else None,
                "RSI_14": round(latest['RSI'], 2) if pd.notna(latest['RSI']) else None,
                "MACD": round(latest['MACD'], 2) if pd.notna(latest['MACD']) else None,
                "MACD_signal": round(latest['MACD_signal'], 2) if pd.notna(latest['MACD_signal']) else None,
                "MACD_histogram": round(latest['MACD_hist'], 2) if pd.notna(latest['MACD_hist']) else None,
                "볼린저_상단": round(latest['BB_upper'], 2) if pd.notna(latest['BB_upper']) else None,
                "볼린저_하단": round(latest['BB_lower'], 2) if pd.notna(latest['BB_lower']) else None,
                "일목_전환선": round(latest['Ichimoku_conversion'], 2) if pd.notna(latest['Ichimoku_conversion']) else None,
                "일목_기준선": round(latest['Ichimoku_base'], 2) if pd.notna(latest['Ichimoku_base']) else None,
                "일목_선행스팬A": round(latest['Ichimoku_span_a'], 2) if pd.notna(latest['Ichimoku_span_a']) else None,
                "일목_선행스팬B": round(latest['Ichimoku_span_b'], 2) if pd.notna(latest['Ichimoku_span_b']) else None,
                "일목_후행스팬": round(latest['Ichimoku_lagging'], 2) if pd.notna(latest['Ichimoku_lagging']) else None,
            },
            "기간내_최고가": round(df['High'].max(), 2),
            "기간내_최저가": round(df['Low'].min(), 2),
            "시가총액": info.get("marketCap"),
            "52주_최고": info.get("fiftyTwoWeekHigh"),
            "52주_최저": info.get("fiftyTwoWeekLow"),
            "PER": info.get("trailingPE"),
            "최근10일_OHLCV": []
        }
    
        for _, row in df.tail(10).iterrows():
            result["최근10일_OHLCV"].append({
                "날짜": str(row.name.date()),
                "시가": round(row['Open'], 2),
                "고가": round(row['High'], 2),
                "저가": round(row['Low'], 2),
                "종가": round(row['Close'], 2),
                "거래량": int(row['Volume'])
            })
    
        return json.dumps(result, ensure_ascii=False, indent=2)
  • server.py:134-135 (registration)
    Tool registration via @mcp.tool() decorator on FastMCP instance 'Stock Analyzer' (defined on line 14).
    @mcp.tool()
    def get_us_stock_analysis(symbol: str, days: int = 120) -> str:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It only states 'analyzes' without clarifying whether it is read-only, what side effects exist, or any behavioral traits beyond basic analysis. It does not describe the nature of the analysis or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise with two sentences plus a parameter list. Every piece of information is essential, and it is front-loaded with the main purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having an output schema, the description does not explain what the tool returns or how to interpret results. It also fails to mention any usage context relative to siblings, making it incomplete for a tool with multiple similar alternatives.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description adds value by providing examples for 'symbol' (e.g., 'AAPL') and clarifying 'days' as the inquiry period in days with default 120. This is adequate but not extensive; no constraints or allowed values are given.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it analyzes US stock tickers, using the verb 'analyzes' and specifying 'US stock'. This distinguishes it from the sibling 'get_stock_analysis' which likely covers other markets, though not explicitly stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'get_stock_analysis' or 'screen_us_momentum'. No when-not scenarios or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/Juuuuuuni/stock-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server