@@ -456,6 +456,7 @@ def sharepoint_excel(
456456 include_frozen_rows : bool = True ,
457457 include_cell_styles : bool = False ,
458458 expand_axis_range : bool = False ,
459+ include_row_data : bool = False ,
459460 ctx : Context | None = None ,
460461) -> str :
461462 """
@@ -478,6 +479,9 @@ def sharepoint_excel(
478479 expand_axis_range: 単一列/行の部分範囲を開始側に自動拡張(default: false)
479480 True: 例 "J50:J100" → "J1:J100"(行1に拡張)
480481 frozen_rows=0でヘッダー文脈が不明な場合に使用
482+ include_row_data: 検索モード時、マッチしたセルの行全体のデータを含める(default: false)
483+ True: 各マッチに row_data(同一行の非nullセル一覧)を追加
484+ 読み取りモードでは無視される
481485 ctx: FastMCP context (injected automatically)
482486
483487 Returns:
@@ -497,7 +501,9 @@ def sharepoint_excel(
497501
498502 # 検索モード
499503 if query :
500- return parser .search_cells (file_path , query , sheet_name = sheet )
504+ return parser .search_cells (
505+ file_path , query , sheet_name = sheet , include_row_data = include_row_data
506+ )
501507
502508 # 読み取りモード
503509 return parser .parse_to_json (
@@ -544,7 +550,7 @@ def register_tools():
544550 mcp .tool (
545551 description = (
546552 "Read or search Excel files in SharePoint. "
547- "Search mode: use 'query' parameter to find cells containing specific text (returns cell locations). "
553+ "Search mode: use 'query' parameter to find cells containing specific text (returns cell locations and optionally row data ). "
548554 "Read mode: use 'sheet' and 'cell_range' parameters to retrieve data from specific sections. "
549555 "When cell_range is specified with include_frozen_rows=True (default), frozen rows are automatically "
550556 "included even if they are outside the specified range. frozen_rows indicates the number of header rows "
@@ -555,10 +561,13 @@ def register_tools():
555561 "Header detection: For sheets with frozen_rows > 0, headers are automatically included with include_frozen_rows=True (default). "
556562 "For sheets with frozen_rows=0, headers are not automatically included and context may be unclear. "
557563 "ALWAYS read exactly 5 rows for header check: 'A1:Z5' (NOT 'A1:Z50' or more). "
564+ "IMPORTANT: include_row_data=True returns matched row data only (not headers), same-row matches duplicate data. "
565+ "Always read 'A1:Z5' first for header context. Effective for <200 matches. "
558566 "Prefer 'query' search when possible to locate data first. "
559- "Workflow: 1) Search OR read 'A1:Z5' for header check, "
560- "2) Read specific range (include_frozen_rows adds frozen headers automatically), "
561- "3) If frozen_rows=0 and header context is unclear, retry with expand_axis_range=True "
567+ "Workflow: 1) Read 'A1:Z5' for header check (REQUIRED for understanding column structure), "
568+ "2) Search with query (optionally with include_row_data=True to get matched row data), "
569+ "3) Read specific range if needed (include_frozen_rows adds frozen headers automatically), "
570+ "4) If frozen_rows=0 and header context is unclear, retry with expand_axis_range=True "
562571 "to auto-include row 1 (for columns) or column A (for rows)."
563572 )
564573 )(sharepoint_excel )
0 commit comments