メインコンテンツまでスキップ

AI Search MCP サーバー

備考

プレビュー

この機能は パブリック プレビュー段階です。

AI Search MCP サーバーは、エージェントがAI Search インデックス に対してセマンティック検索をランして関連ドキュメントを検索できるようにする Databricks ワークスペースMCP Endpoint であり、結果は Unity Catalog の権限によって制御されます。インデックスのクエリには、Databricks管理の埋め込みが必要です。

ヒント

推奨アプローチ

新規の Python エージェントの場合は、AI Bridge retriever ツールを使用して、AI Search インデックスを直接クエリーします。

URL パターン

OAuthスコープ

https://<workspace-hostname>/api/2.0/mcp/ai-search/{catalog}/{schema}/{index_name}

ai-search

URL パターン

OAuthスコープ

https://<workspace-hostname>/api/2.0/mcp/ai-search/{catalog}/{schema}/{index_name}

ai-search

注記

AI Search は以前、ベクトル検索と呼ばれていました。以前の /api/2.0/mcp/vector-search/ URL プレフィックスと vector-search スコープは引き続き機能します。

AI Search _meta パラメーター​

AI Search では、次の _meta パラメーターがサポートされています。

パラメーター名

Type

説明

columns

str

検索結果で返す列名のコンマ区切りリスト。

例: "id,text,metadata"

指定されていない場合、すべての列(「__」で始まる内部列を除く)が返されます。

columns_to_rerank

str

リランキングモデルが再スコアリングに使用するコンテンツの列名のコンマ区切りリスト。リランカーはこのコンテンツを使用してすべての検索結果を再スコアリングし、関連性を向上させます。

例: "text,title,description"

指定がない場合、リランキングは実行されません。

filters

str

検索に適用するフィルターを含むJSON文字列。有効なJSONである必要があります。

例: '{"updated_after": "2024-01-01"}'

指定がない場合、フィルターは適用されません。

include_score

bool

返される結果に類似度スコアを含めるかどうか。

サポートされている値: "true" または "false"

デフォルト: "false"

num_results

int

返される結果の数。

例: "5"

query_type

str

結果の取得に使用する検索アルゴリズム。

サポートされている値: "ANN" (近似最近傍、default) または "HYBRID" (ベクトル検索とキーワード検索を組み合わせる)

デフォルト: "ANN"

score_threshold

float

結果をフィルタリングするための最小類似度スコアのthreshold。このthresholdを下回るスコアの結果は除外されます。

例: "0.7"

指定がない場合、スコアのフィルタリングは適用されません。

パラメーター名

Type

説明

columns

str

検索結果で返す列名のコンマ区切りリスト。

例: "id,text,metadata"

指定されていない場合、すべての列(「__」で始まる内部列を除く)が返されます。

columns_to_rerank

str

リランキングモデルが再スコアリングに使用するコンテンツの列名のコンマ区切りリスト。リランカーはこのコンテンツを使用してすべての検索結果を再スコアリングし、関連性を向上させます。

例: "text,title,description"

指定がない場合、リランキングは実行されません。

filters

str

検索に適用するフィルターを含むJSON文字列。有効なJSONである必要があります。

例: '{"updated_after": "2024-01-01"}'

指定がない場合、フィルターは適用されません。

include_score

bool

返される結果に類似度スコアを含めるかどうか。

サポートされている値: "true" または "false"

デフォルト: "false"

num_results

int

返される結果の数。

例: "5"

query_type

str

結果の取得に使用する検索アルゴリズム。

サポートされている値: "ANN" (近似最近傍、default) または "HYBRID" (ベクトル検索とキーワード検索を組み合わせる)

デフォルト: "ANN"

score_threshold

float

結果をフィルタリングするための最小類似度スコアのthreshold。このthresholdを下回るスコアの結果は除外されます。

例: "0.7"

指定がない場合、スコアのフィルタリングは適用されません。

これらのパラメーターに関する詳細情報については、AI Search Python SDK ドキュメントを参照してください。

例:AI Searchの検索結果の最大数とフィルターを構成する​

この例では、_metaパラメーターを使用してAI Searchの動作を構成し、公式のPython MCP SDKを使用してエージェントからの動的クエリーを可能にする方法を示します。

このシナリオでは、次のことを行います:

  • 一貫した応答時間を確保するため、検索結果は常に3つのアイテムに制限してください。
  • 関連性を確認するために、最近のドキュメント(2024年1月1日以降に更新)のみを検索します
  • 純粋なベクトル検索よりも高い精度を得るには、ハイブリッド検索を使用します
  • 特定の列(id、text、metadata)のみを返します
  • 結果に類似度スコアを含める
  • 類似度スコアが0.5未満の結果を除外する
  • 関連性を向上させるために、テキスト列とタイトル列で再ランク付けを使用します

この例をランするには、管理対象 MCP 開発用の Python 環境をセットアップしてください。

Python
# Import required libraries for MCP client and Databricks authentication
import asyncio
from databricks.sdk import WorkspaceClient
from databricks_mcp.oauth_provider import DatabricksOAuthClientProvider
from mcp.client.streamable_http import streamablehttp_client
from mcp.client.session import ClientSession
from mcp.types import CallToolRequest, CallToolResult

async def run_vector_search_tool_call_with_meta():
# Initialize Databricks workspace client for authentication
workspace_client = WorkspaceClient()

# Construct the MCP server URL for your specific catalog and schema
# Replace <workspace-hostname>, YOUR_CATALOG, and YOUR_SCHEMA with your values
mcp_server_url = "https://<workspace-hostname>/api/2.0/mcp/ai-search/YOUR_CATALOG/YOUR_SCHEMA"

# Establish connection to the MCP server with OAuth authentication
async with streamablehttp_client(
url=mcp_server_url,
auth=DatabricksOAuthClientProvider(workspace_client),
) as (read_stream, write_stream, _):

# Create an MCP session for making tool calls
async with ClientSession(read_stream, write_stream) as session:
# Initialize the session before making requests
await session.initialize()

# Create the tool call request with both dynamic and preset parameters
request = CallToolRequest(
method="tools/call",
params={
# Tool name follows the pattern: CATALOG__SCHEMA__INDEX_NAME
"name": "YOUR_CATALOG__YOUR_SCHEMA__YOUR_INDEX_NAME",

# Dynamic arguments - typically provided by your AI agent or user input
"arguments": {
"query": "How do I reset my password?" # This comes from your agent
},

# Meta parameters - preset configuration to control search behavior
"_meta": {
"num_results": "3", # Limit to 3 results for consistent performance
"filters": '{"updated_after": "2024-01-01"}', # JSON string for date filtering
"query_type": "HYBRID", # Use hybrid search for better relevance
"columns": "id,text,metadata", # Return only specific columns
"score_threshold": "0.5", # Filter out results with similarity score < 0.5
"include_score": "true", # Include similarity scores in results
"columns_to_rerank": "text,title" # Use reranker on these columns for better quality
}
}
)

# Send the request and get the response
response = await session.send_request(request, CallToolResult)
return response

# Execute the async function and get results
response = asyncio.run(run_vector_search_tool_call_with_meta())