このページは機械翻訳です。英語版がソースであり、より正確または最新の場合があります。 英語で表示

MCP サーバー - 開発者統合

このガイドでは、finlight MCP サーバーとのプログラムによる統合を扱います。カスタム AI アプリケーションの構築、ニュース取得の自動化、または既存システムへの金融ニュースの統合に使用してください。


INFOエンドポイント

サーバー情報

環境URL
本番https://mcp.finlight.me

サーバーは HTTP 上の JSON-RPC 2.0 を介して MCP(Model Context Protocol) を実装します。


AUTHAPI キー

認証

すべてのツール呼び出しには Bearer トークンによる認証が必要です。finlight の API キーがアクセストークンとして機能します。

Authorization: Bearer YOUR_API_KEY

自動化された OAuth フロー(Claude Desktop など)では、サーバーは PKCE 付きの OAuth 2.0 を実装します。詳細は OAuth フローを参照してください。


QUICKSTART

クイックスタート

cURL を使う

利用可能なツールを一覧表示する:

curl -X POST https://mcp.finlight.me \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list"
  }'

記事を検索する:

curl -X POST https://mcp.finlight.me \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "search_articles",
      "arguments": {
        "query": "NVIDIA earnings",
        "tickers": ["NVDA"],
        "pageSize": 10
      }
    }
  }'

TypeScript を使う

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const transport = new StreamableHTTPClientTransport(
  new URL("https://mcp.finlight.me"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${process.env.FINLIGHT_API_KEY}`,
      },
    },
  }
);

const client = new Client({
  name: "my-app",
  version: "1.0.0",
});

await client.connect(transport);

// List available tools
const tools = await client.listTools();
console.log("Available tools:", tools);

// Search articles
const result = await client.callTool({
  name: "search_articles",
  arguments: {
    query: "Federal Reserve interest rates",
    from: "2024-01-01",
    pageSize: 5,
  },
});

console.log("Articles:", result);

Python を使う

import requests
import json

API_KEY = "your-api-key"
MCP_URL = "https://mcp.finlight.me"

def mcp_request(method: str, params: dict = None):
    response = requests.post(
        MCP_URL,
        headers={
            "Content-Type": "application/json",
            "Authorization": f"Bearer {API_KEY}",
        },
        json={
            "jsonrpc": "2.0",
            "id": 1,
            "method": method,
            "params": params or {},
        },
    )
    return response.json()

# List available tools
tools = mcp_request("tools/list")
print("Available tools:", json.dumps(tools, indent=2))

# Search articles
articles = mcp_request("tools/call", {
    "name": "search_articles",
    "arguments": {
        "query": "Tesla Model 3",
        "tickers": ["TSLA"],
        "from": "2024-01-01",
        "pageSize": 10,
    },
})
print("Articles:", json.dumps(articles, indent=2))

TOOLSリファレンス

利用可能なツール

search_articles

高度なフィルタリングと感情分析で金融ニュース記事を検索します。

パラメータ:

パラメータ説明
querystringブール演算子(AND、OR、NOT)とフィールドフィルター(ticker:AAPLsource:reuters.com)付きの検索クエリ
tickersstring[]ティッカーシンボルでフィルタリング(例:["AAPL", "NVDA"]
sourcesstring[]特定のニュースソースドメインに限定
optInSourcesstring[]既定のセットにソースを追加(置き換えではなく)
excludeSourcesstring[]結果から特定のソースを除外
countriesstring[]ISO 3166-1 alpha-2 国コードでフィルタリング
fromstring開始日(YYYY-MM-DD または ISO 8601)
tostring終了日(YYYY-MM-DD または ISO 8601)
languagestring言語コード(既定:"en")
includeContentboolean記事の全文を含める(サブスクリプションが必要)
includeEntitiesbooleanタグ付けされた企業エンティティを含める
excludeEmptyContentbooleanコンテンツのない記事をスキップ
order"ASC" | "DESC"並び順(既定:DESC = 新しい順)
orderBy"publishDate" | "createdAt" | "revisedDate"並べ替えフィールド — revisedDate は最新の改訂日で並べ替え
pageSizenumber1 ページあたりの結果数(1-100、既定:20)
pagenumberページ番号(既定:1)

リクエスト例:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search_articles",
    "arguments": {
      "query": "earnings report",
      "tickers": ["AAPL", "MSFT"],
      "from": "2024-01-01",
      "to": "2024-03-31",
      "language": "en",
      "pageSize": 20
    }
  }
}

レスポンス例:

{
  "jsonrpc": "2.0",
  "result": {
    "content": [{
      "type": "text",
      "text": "{\"articles\":[{\"title\":\"Apple Reports Record Q1...\",\"summary\":\"...\",\"link\":\"https://...\",\"publishDate\":\"2024-02-01T16:30:00Z\",\"source\":\"www.reuters.com\",\"sentiment\":\"positive\",\"sentimentConfidence\":0.92}],\"totalResults\":847,\"page\":1,\"pageSize\":20}"
    }]
  },
  "id": 1
}

get_article_by_link

URL で特定の記事を取得します。

パラメータ:

パラメータ必須説明
linkstringはい記事の完全な URL
includeContentbooleanいいえ記事の全文を含める
includeEntitiesbooleanいいえタグ付けされた企業エンティティを含める

リクエスト例:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_article_by_link",
    "arguments": {
      "link": "https://www.reuters.com/technology/example-article",
      "includeContent": true,
      "includeEntities": true
    }
  }
}

list_sources

利用可能なすべてのニュースソースをメタデータ付きで取得します。

パラメータ: なし

リクエスト例:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "list_sources",
    "arguments": {}
  }
}

レスポンスに含まれるもの:

  • domain - ソースのウェブサイトのドメイン
  • isDefaultSource - 既定の検索に含まれるかどうか
  • isContentAvailable - 全文取得がサポートされているかどうか

PROTOCOLJSON-RPC

MCP プロトコルメソッド

サーバーは次の MCP プロトコルメソッドを実装します:

メソッド説明
initializeMCP セッションを初期化する
notifications/initialized初期化完了を確認する
tools/list利用可能なツールとそのスキーマを一覧表示する
tools/call引数付きでツールを実行する
pingヘルスチェック

Initialize の例:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "my-client",
      "version": "1.0.0"
    }
  }
}

レスポンス:

{
  "jsonrpc": "2.0",
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": {
      "tools": {}
    },
    "serverInfo": {
      "name": "finlight-news-api",
      "version": "1.0.0"
    }
  },
  "id": 1
}

OAUTH認証

OAuth フロー

OAuth をサポートするクライアント(Claude Desktop など)向けに、サーバーは PKCE 付きの OAuth 2.0 を実装します。

エンドポイント

エンドポイントメソッド説明
/.well-known/oauth-protected-resourceGET保護されたリソースのメタデータ
/.well-known/oauth-authorization-serverGET認可サーバーのメタデータ
/registerPOST動的クライアント登録
/authorizeGET認可ページ
/authorize/submitPOST認可を処理する
/tokenPOSTコードをトークンと交換する

フローの概要

1. Client discovers OAuth endpoints via .well-known
2. Client optionally registers via /register
3. Client redirects user to /authorize with PKCE challenge
4. User enters API key and submits
5. Server redirects back with authorization code
6. Client exchanges code + verifier for access token
7. Client uses access token as Bearer token for API calls

セキュリティ機能

  • PKCE 必須 - 認可コードの傍受を防止
  • 自己暗号化コード - AES-256-GCM で暗号化、ステートレス
  • 短命なコード - 120 秒で期限切れ
  • Redirect URI 検証 - コードは元の URI に紐づけられる

ERRORSトラブルシューティング

エラー処理

JSON-RPC エラーコード

コードメッセージ説明
-32700Parse error無効な JSON
-32600Invalid Requestjsonrpc または method がない
-32601Method not found不明なメソッド
-32602Invalid params無効なツールパラメータ
-32001UnauthorizedAPI キーが欠落または無効
-32603Internal errorサーバー側のエラー

API エラーレスポンス

失敗したツール呼び出しはエラー構造を返します:

{
  "jsonrpc": "2.0",
  "result": {
    "isError": true,
    "content": [{
      "type": "text",
      "text": "Error: Invalid API key"
    }]
  },
  "id": 1
}

一般的な HTTP レベルのエラー:

ステータス説明
401無効な API キー
403サブスクリプションがこの操作を許可していない
429レート制限を超過
400検証エラー

LIMITSクォータ

レート制限

レート制限は finlight のサブスクリプションプランによって異なります。制限を超えると、API は 429 ステータスコードを返します。

現在の使用状況と制限は app.finlight.me で確認してください。


SUPPORTヘルプ

サポート