Skip to content

server

gurume.server

MCP Server for Tabelog restaurant search using FastMCP.

This module keeps the FastMCP instance and tool entrypoints together while delegating response schemas and helper logic to focused modules.

CourseOutput

Bases: BaseModel

Structured course output.

CuisineListOutput

Bases: BaseModel

Structured cuisine list output for MCP clients.

CuisineOutput

Bases: BaseModel

Cuisine type output schema.

MenuItemOutput

Bases: BaseModel

Structured menu item output.

RestaurantDetailOutput

Bases: BaseModel

Structured restaurant detail output for MCP clients.

RestaurantOutput

Bases: BaseModel

Restaurant search result output schema.

RestaurantSearchOutput

Bases: BaseModel

Structured restaurant search output for MCP clients.

ReviewOutput

Bases: BaseModel

Structured restaurant review output.

SearchFiltersOutput

Bases: BaseModel

Normalized filters used for a search request.

SearchMetaOutput

Bases: BaseModel

Pagination and result metadata for restaurant search.

SuggestionListOutput

Bases: BaseModel

Structured suggestion list output for MCP clients.

SuggestionOutput

Bases: BaseModel

Area or keyword suggestion output schema.

ToolErrorOutput

Bases: BaseModel

Structured MCP tool error output for agent-friendly recovery.

run

run(
    transport: TransportType = "stdio",
    host: str = "127.0.0.1",
    port: int = 8000,
    path: str = "/mcp",
) -> None

Synchronous entry point for CLI

This function is called when running 'gurume mcp' command.

Parameters:

Name Type Description Default
transport TransportType

MCP transport to use ("stdio", "sse", or "streamable-http").

'stdio'
host str

Bind host for HTTP transports (ignored for stdio).

'127.0.0.1'
port int

Bind port for HTTP transports (ignored for stdio).

8000
path str

HTTP mount path for the MCP endpoint (streamable-http uses streamable_http_path; sse uses sse_path).

'/mcp'
Source code in src/gurume/server.py
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
def run(
    transport: TransportType = "stdio",
    host: str = "127.0.0.1",
    port: int = 8000,
    path: str = "/mcp",
) -> None:
    """Synchronous entry point for CLI

    This function is called when running 'gurume mcp' command.

    Args:
        transport: MCP transport to use ("stdio", "sse", or "streamable-http").
        host: Bind host for HTTP transports (ignored for stdio).
        port: Bind port for HTTP transports (ignored for stdio).
        path: HTTP mount path for the MCP endpoint (streamable-http uses
            ``streamable_http_path``; sse uses ``sse_path``).
    """
    if transport != "stdio":
        mcp.settings.host = host
        mcp.settings.port = port
        if transport == "streamable-http":
            mcp.settings.streamable_http_path = path
        else:  # sse
            mcp.settings.sse_path = path
    mcp.run(transport=transport)

tabelog_get_area_suggestions async

tabelog_get_area_suggestions(
    query: Annotated[
        str,
        Field(
            description="Area query in Japanese, hiragana, or romaji. Use this before searching when area names are ambiguous.",
            min_length=1,
        ),
    ],
) -> SuggestionListOutput

Get area and station suggestions for validating user-provided locations.

Source code in src/gurume/server.py
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,
        openWorldHint=True,
    ),
    structured_output=True,
)
async def tabelog_get_area_suggestions(
    query: Annotated[
        str,
        Field(
            description=(
                "Area query in Japanese, hiragana, or romaji. Use this before searching when area names are ambiguous."
            ),
            min_length=1,
        ),
    ],
) -> SuggestionListOutput:
    """Get area and station suggestions for validating user-provided locations."""
    normalized_query = query.strip()

    try:
        if not normalized_query:
            raise ValueError("query parameter cannot be empty")

        suggestions = await get_area_suggestions_async(normalized_query)
    except ValueError as e:
        return _build_suggestion_list_error_output(
            normalized_query,
            _build_tool_error(
                error_code="invalid_parameters",
                message=f"Invalid suggestion query: {e}",
                retryable=False,
                suggested_action="Pass a non-empty area query string before calling this tool again.",
                detail=str(e),
            ),
        )
    except RuntimeError as e:
        return _build_suggestion_list_error_output(
            normalized_query,
            _build_tool_error(
                error_code="upstream_unavailable",
                message="Area suggestion request failed because the upstream service was unavailable.",
                retryable=True,
                suggested_action="Retry later, or try a broader area query.",
                detail=str(e),
            ),
        )
    except Exception as e:  # noqa: BLE001
        return _build_suggestion_list_error_output(
            normalized_query,
            _build_tool_error(
                error_code="internal_error",
                message="Area suggestion request failed unexpectedly.",
                retryable=True,
                suggested_action="Retry the tool call. If the same error repeats, inspect the server logs.",
                detail=str(e),
            ),
        )

    return _build_suggestion_list_output(normalized_query, _to_suggestion_outputs(suggestions))

tabelog_get_keyword_suggestions async

tabelog_get_keyword_suggestions(
    query: Annotated[
        str,
        Field(
            description="Keyword query in Japanese, hiragana, or romaji. Use this to detect Genre2 cuisines or restaurant-name suggestions before searching.",
            min_length=1,
        ),
    ],
) -> SuggestionListOutput

Get keyword suggestions for cuisine names, restaurant names, and popular search variants.

Source code in src/gurume/server.py
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,
        openWorldHint=True,
    ),
    structured_output=True,
)
async def tabelog_get_keyword_suggestions(
    query: Annotated[
        str,
        Field(
            description=(
                "Keyword query in Japanese, hiragana, or romaji. Use this to detect Genre2 cuisines or "
                "restaurant-name suggestions before searching."
            ),
            min_length=1,
        ),
    ],
) -> SuggestionListOutput:
    """Get keyword suggestions for cuisine names, restaurant names, and popular search variants."""
    normalized_query = query.strip()

    try:
        if not normalized_query:
            raise ValueError("query parameter cannot be empty")

        suggestions = await get_keyword_suggestions_async(normalized_query)
    except ValueError as e:
        return _build_suggestion_list_error_output(
            normalized_query,
            _build_tool_error(
                error_code="invalid_parameters",
                message=f"Invalid suggestion query: {e}",
                retryable=False,
                suggested_action="Pass a non-empty keyword query string before calling this tool again.",
                detail=str(e),
            ),
        )
    except RuntimeError as e:
        return _build_suggestion_list_error_output(
            normalized_query,
            _build_tool_error(
                error_code="upstream_unavailable",
                message="Keyword suggestion request failed because the upstream service was unavailable.",
                retryable=True,
                suggested_action="Retry later, or try a shorter keyword query.",
                detail=str(e),
            ),
        )
    except Exception as e:  # noqa: BLE001
        return _build_suggestion_list_error_output(
            normalized_query,
            _build_tool_error(
                error_code="internal_error",
                message="Keyword suggestion request failed unexpectedly.",
                retryable=True,
                suggested_action="Retry the tool call. If the same error repeats, inspect the server logs.",
                detail=str(e),
            ),
        )

    return _build_suggestion_list_output(normalized_query, _to_suggestion_outputs(suggestions))

tabelog_get_restaurant_details async

tabelog_get_restaurant_details(
    restaurant_url: Annotated[
        str,
        Field(
            description="Tabelog restaurant URL from search results. Must start with https://tabelog.com/.",
            pattern="^https://tabelog\\.com/.+",
        ),
    ],
    fetch_reviews: Annotated[
        bool,
        Field(
            default=True,
            description="Whether to fetch review pages from Tabelog.",
        ),
    ] = True,
    fetch_menu: Annotated[
        bool,
        Field(
            default=True,
            description="Whether to fetch the restaurant menu page.",
        ),
    ] = True,
    fetch_courses: Annotated[
        bool,
        Field(
            default=True,
            description="Whether to fetch the restaurant course page.",
        ),
    ] = True,
    max_review_pages: Annotated[
        int,
        Field(
            default=1,
            description="Maximum number of review pages to fetch when fetch_reviews is true.",
            ge=1,
        ),
    ] = 1,
) -> RestaurantDetailOutput

Fetch detailed restaurant information including reviews, menu items, and courses.

Source code in src/gurume/server.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,
        openWorldHint=True,
    ),
    structured_output=True,
)
async def tabelog_get_restaurant_details(
    restaurant_url: Annotated[
        str,
        Field(
            description="Tabelog restaurant URL from search results. Must start with https://tabelog.com/.",
            pattern=r"^https://tabelog\.com/.+",
        ),
    ],
    fetch_reviews: Annotated[
        bool,
        Field(default=True, description="Whether to fetch review pages from Tabelog."),
    ] = True,
    fetch_menu: Annotated[
        bool,
        Field(default=True, description="Whether to fetch the restaurant menu page."),
    ] = True,
    fetch_courses: Annotated[
        bool,
        Field(default=True, description="Whether to fetch the restaurant course page."),
    ] = True,
    max_review_pages: Annotated[
        int,
        Field(
            default=1,
            description="Maximum number of review pages to fetch when fetch_reviews is true.",
            ge=1,
        ),
    ] = 1,
) -> RestaurantDetailOutput:
    """Fetch detailed restaurant information including reviews, menu items, and courses."""
    try:
        _validate_detail_params(restaurant_url, fetch_reviews, fetch_menu, fetch_courses, max_review_pages)
        request = RestaurantDetailRequest(
            restaurant_url=restaurant_url,
            fetch_reviews=fetch_reviews,
            fetch_menu=fetch_menu,
            fetch_courses=fetch_courses,
            max_review_pages=max_review_pages,
        )
        detail = await request.fetch()
    except ValueError as e:
        return _build_detail_error_output(
            restaurant_url=restaurant_url,
            fetch_reviews=fetch_reviews,
            fetch_menu=fetch_menu,
            fetch_courses=fetch_courses,
            max_review_pages=max_review_pages,
            error=_build_tool_error(
                error_code="invalid_parameters",
                message=f"Invalid detail request parameters: {e}",
                retryable=False,
                suggested_action=(
                    "Pass a non-empty `https://tabelog.com/` restaurant URL and enable at least one fetch option."
                ),
                detail=str(e),
            ),
        )
    except RuntimeError as e:
        return _build_detail_error_output(
            restaurant_url=restaurant_url,
            fetch_reviews=fetch_reviews,
            fetch_menu=fetch_menu,
            fetch_courses=fetch_courses,
            max_review_pages=max_review_pages,
            error=_build_tool_error(
                error_code="upstream_unavailable",
                message="Restaurant detail request failed because the upstream service did not return usable data.",
                retryable=True,
                suggested_action="Verify the restaurant URL from search results and retry later.",
                detail=str(e),
            ),
        )
    except Exception as e:  # noqa: BLE001
        return _build_detail_error_output(
            restaurant_url=restaurant_url,
            fetch_reviews=fetch_reviews,
            fetch_menu=fetch_menu,
            fetch_courses=fetch_courses,
            max_review_pages=max_review_pages,
            error=_build_tool_error(
                error_code="internal_error",
                message="Restaurant detail request failed unexpectedly.",
                retryable=True,
                suggested_action="Retry the tool call. If the same error repeats, inspect the server logs.",
                detail=str(e),
            ),
        )

    return _to_detail_output(
        detail,
        fetch_reviews=fetch_reviews,
        fetch_menu=fetch_menu,
        fetch_courses=fetch_courses,
        max_review_pages=max_review_pages,
    )

tabelog_list_cuisines async

tabelog_list_cuisines() -> CuisineListOutput

Get complete list of all 45+ supported Japanese cuisine types with their Tabelog genre codes.

WHEN TO USE: - Before calling tabelog_search_restaurants with cuisine parameter to verify available options - Providing cuisine type suggestions/autocomplete to users - Validating user's cuisine input against supported types - Building UI dropdown menus or selection lists

RETURN FORMAT: Returns list of all supported cuisines: - name: Cuisine name in Japanese (e.g., 'すき焼き', '焼肉', 'ラーメン') - code: Tabelog genre code (e.g., 'RC0107', 'RC0103') - used internally for filtering

CUISINE CATEGORIES (45+ types total): - Japanese: すき焼き, 焼肉, 寿司, ラーメン, うなぎ, そば, うどん, 天ぷら, とんかつ, 焼き鳥, お好み焼き, たこ焼き - Hotpot/Nabe: しゃぶしゃぶ, もつ鍋, 水炊き - Izakaya: 居酒屋, 焼酎バー, 日本酒バー - Western: イタリアン, フレンチ, スペイン料理, ハンバーガー, ステーキ - Asian: 中華料理, 韓国料理, タイ料理, インド料理, ベトナム料理 - Other: カレー, カフェ, スイーツ, パン, ラーメン

WORKFLOW EXAMPLE: 1. User asks: 'Find sukiyaki restaurants in Tokyo' 2. Call tabelog_list_cuisines to verify 'すき焼き' is supported → Returns {name: 'すき焼き', code: 'RC0107'} 3. Call tabelog_search_restaurants with area='東京', cuisine='すき焼き'

NO INPUT REQUIRED: This tool takes no parameters, simply call it to get the full list.

Returns:

Type Description
CuisineListOutput

List of all supported cuisine types with their genre codes

Raises:

Type Description
RuntimeError

If cuisine list retrieval fails (should be rare as data is static)

Source code in src/gurume/server.py
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,
    ),
    structured_output=True,
)
async def tabelog_list_cuisines() -> CuisineListOutput:
    """Get complete list of all 45+ supported Japanese cuisine types with their Tabelog genre codes.

    **WHEN TO USE**:
    - Before calling `tabelog_search_restaurants` with `cuisine` parameter to verify available options
    - Providing cuisine type suggestions/autocomplete to users
    - Validating user's cuisine input against supported types
    - Building UI dropdown menus or selection lists

    **RETURN FORMAT**:
    Returns list of all supported cuisines:
    - name: Cuisine name in Japanese (e.g., 'すき焼き', '焼肉', 'ラーメン')
    - code: Tabelog genre code (e.g., 'RC0107', 'RC0103') - used internally for filtering

    **CUISINE CATEGORIES** (45+ types total):
    - Japanese: すき焼き, 焼肉, 寿司, ラーメン, うなぎ, そば, うどん, 天ぷら, とんかつ, 焼き鳥, お好み焼き, たこ焼き
    - Hotpot/Nabe: しゃぶしゃぶ, もつ鍋, 水炊き
    - Izakaya: 居酒屋, 焼酎バー, 日本酒バー
    - Western: イタリアン, フレンチ, スペイン料理, ハンバーガー, ステーキ
    - Asian: 中華料理, 韓国料理, タイ料理, インド料理, ベトナム料理
    - Other: カレー, カフェ, スイーツ, パン, ラーメン

    **WORKFLOW EXAMPLE**:
    1. User asks: 'Find sukiyaki restaurants in Tokyo'
    2. Call `tabelog_list_cuisines` to verify 'すき焼き' is supported → Returns {name: 'すき焼き', code: 'RC0107'}
    3. Call `tabelog_search_restaurants` with area='東京', cuisine='すき焼き'

    **NO INPUT REQUIRED**: This tool takes no parameters, simply call it to get the full list.

    Returns:
        List of all supported cuisine types with their genre codes

    Raises:
        RuntimeError: If cuisine list retrieval fails (should be rare as data is static)
    """
    try:
        cuisines = get_all_genres()
    except ValueError as e:
        return _build_cuisine_list_error_output(
            _build_tool_error(
                error_code="internal_error",
                message="Cuisine list retrieval failed unexpectedly.",
                retryable=True,
                suggested_action="Retry the tool call. If the same error repeats, inspect the server logs.",
                detail=str(e),
            )
        )
    except Exception as e:  # noqa: BLE001
        return _build_cuisine_list_error_output(
            _build_tool_error(
                error_code="internal_error",
                message="Cuisine list retrieval failed unexpectedly.",
                retryable=True,
                suggested_action="Retry the tool call. If the same error repeats, inspect the server logs.",
                detail=str(e),
            )
        )

    return _build_cuisine_list_output(
        [CuisineOutput(name=cuisine, code=code) for cuisine in cuisines if (code := get_genre_code(cuisine))]
    )

tabelog_search_restaurants async

tabelog_search_restaurants(
    area: Annotated[
        str | None,
        Field(
            default=None,
            description="Area name in Japanese. Prefer a validated prefecture, city, or station from `tabelog_get_area_suggestions`.",
            min_length=1,
        ),
    ] = None,
    keyword: Annotated[
        str | None,
        Field(
            default=None,
            description="General keyword for restaurant names or free-text matching. Use `cuisine` for cuisine-type searches.",
            min_length=1,
        ),
    ] = None,
    cuisine: Annotated[
        str | None,
        Field(
            default=None,
            description="Cuisine name in Japanese. Validate with `tabelog_get_keyword_suggestions` or `tabelog_list_cuisines` before searching.",
            min_length=1,
        ),
    ] = None,
    sort: Annotated[
        SortOption,
        Field(
            default="ranking",
            description="Result ordering: ranking, review-count, new-open, or standard.",
        ),
    ] = "ranking",
    limit: Annotated[
        int,
        Field(
            default=20,
            description="Maximum number of restaurants to return from the first fetched page.",
            ge=1,
            le=60,
        ),
    ] = 20,
    page: Annotated[
        int,
        Field(
            default=1,
            description="1-based result page to fetch from Tabelog. Use the returned metadata to continue paging.",
            ge=1,
        ),
    ] = 1,
    reservation_date: Annotated[
        str | None,
        Field(
            default=None,
            description="Reservation date in YYYYMMDD format. Must be used together with reservation_time.",
            pattern="^\\d{8}$",
        ),
    ] = None,
    reservation_time: Annotated[
        str | None,
        Field(
            default=None,
            description="Reservation time in 24-hour HHMM format. Must be used together with reservation_date.",
            pattern="^\\d{4}$",
        ),
    ] = None,
    party_size: Annotated[
        int | None,
        Field(
            default=None,
            description="Optional party size for reservation filtering.",
            ge=1,
        ),
    ] = None,
) -> RestaurantSearchOutput

Search Tabelog restaurants with validated filters and pagination metadata.

Recommended workflow: 1. Validate ambiguous areas with tabelog_get_area_suggestions. 2. Validate cuisines or names with tabelog_get_keyword_suggestions. 3. Search using the normalized area and cuisine values. 4. Use page together with the returned meta.has_next_page and has_more fields to fetch later pages.

Returns a structured envelope with restaurants, applied filters, pagination metadata, and non-fatal warnings that help the caller refine follow-up tool calls.

Source code in src/gurume/server.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,
        openWorldHint=True,
    ),
    structured_output=True,
)
async def tabelog_search_restaurants(
    area: Annotated[
        str | None,
        Field(
            default=None,
            description=(
                "Area name in Japanese. Prefer a validated prefecture, city, or station from "
                "`tabelog_get_area_suggestions`."
            ),
            min_length=1,
        ),
    ] = None,
    keyword: Annotated[
        str | None,
        Field(
            default=None,
            description=(
                "General keyword for restaurant names or free-text matching. Use `cuisine` for cuisine-type searches."
            ),
            min_length=1,
        ),
    ] = None,
    cuisine: Annotated[
        str | None,
        Field(
            default=None,
            description=(
                "Cuisine name in Japanese. Validate with `tabelog_get_keyword_suggestions` or "
                "`tabelog_list_cuisines` before searching."
            ),
            min_length=1,
        ),
    ] = None,
    sort: Annotated[
        SortOption,
        Field(default="ranking", description="Result ordering: ranking, review-count, new-open, or standard."),
    ] = "ranking",
    limit: Annotated[
        int,
        Field(
            default=20,
            description="Maximum number of restaurants to return from the first fetched page.",
            ge=1,
            le=60,
        ),
    ] = 20,
    page: Annotated[
        int,
        Field(
            default=1,
            description="1-based result page to fetch from Tabelog. Use the returned metadata to continue paging.",
            ge=1,
        ),
    ] = 1,
    reservation_date: Annotated[
        str | None,
        Field(
            default=None,
            description="Reservation date in YYYYMMDD format. Must be used together with reservation_time.",
            pattern=r"^\d{8}$",
        ),
    ] = None,
    reservation_time: Annotated[
        str | None,
        Field(
            default=None,
            description="Reservation time in 24-hour HHMM format. Must be used together with reservation_date.",
            pattern=r"^\d{4}$",
        ),
    ] = None,
    party_size: Annotated[
        int | None,
        Field(default=None, description="Optional party size for reservation filtering.", ge=1),
    ] = None,
) -> RestaurantSearchOutput:
    """Search Tabelog restaurants with validated filters and pagination metadata.

    Recommended workflow:
    1. Validate ambiguous areas with `tabelog_get_area_suggestions`.
    2. Validate cuisines or names with `tabelog_get_keyword_suggestions`.
    3. Search using the normalized area and cuisine values.
    4. Use `page` together with the returned `meta.has_next_page` and `has_more` fields to fetch later pages.

    Returns a structured envelope with restaurants, applied filters, pagination metadata,
    and non-fatal warnings that help the caller refine follow-up tool calls.
    """
    try:
        sort_type = _validate_search_params(sort, limit, page, reservation_date, reservation_time, party_size)
        genre_code = _resolve_genre_code(cuisine)

        request = SearchRequest(
            area=area,
            keyword=keyword,
            genre_code=genre_code,
            reservation_date=reservation_date,
            reservation_time=reservation_time,
            party_size=party_size,
            sort_type=sort_type,
            page=page,
            max_pages=1,
        )
        response = await request.search()
    except ValueError as e:
        error_code = "unsupported_cuisine" if cuisine and "Unknown cuisine type" in str(e) else "invalid_parameters"
        return _build_search_error_output(
            limit=limit,
            area=area,
            keyword=keyword,
            cuisine=cuisine,
            sort=sort,
            page=page,
            reservation_date=reservation_date,
            reservation_time=reservation_time,
            party_size=party_size,
            error=_build_tool_error(
                error_code=error_code,
                message=f"Invalid search parameters: {e}",
                retryable=False,
                suggested_action=(
                    "Call `tabelog_list_cuisines` or `tabelog_get_keyword_suggestions` to validate the cuisine first."
                    if error_code == "unsupported_cuisine"
                    else "Check the input fields and retry with values that satisfy the tool schema."
                ),
                detail=str(e),
            ),
        )
    except RuntimeError as e:
        return _build_search_error_output(
            limit=limit,
            area=area,
            keyword=keyword,
            cuisine=cuisine,
            sort=sort,
            page=page,
            reservation_date=reservation_date,
            reservation_time=reservation_time,
            party_size=party_size,
            error=_build_tool_error(
                error_code="upstream_unavailable",
                message="Restaurant search failed because the upstream service did not return usable results.",
                retryable=True,
                suggested_action=(
                    "Retry later, or validate the area and cuisine with suggestion tools before searching again."
                ),
                detail=str(e),
            ),
        )
    except Exception as e:  # noqa: BLE001
        return _build_search_error_output(
            limit=limit,
            area=area,
            keyword=keyword,
            cuisine=cuisine,
            sort=sort,
            page=page,
            reservation_date=reservation_date,
            reservation_time=reservation_time,
            party_size=party_size,
            error=_build_tool_error(
                error_code="internal_error",
                message="Restaurant search failed unexpectedly.",
                retryable=True,
                suggested_action="Retry the tool call. If the same error repeats, inspect the server logs.",
                detail=str(e),
            ),
        )

    if response.status == SearchStatus.ERROR:
        return _build_search_error_output(
            limit=limit,
            area=area,
            keyword=keyword,
            cuisine=cuisine,
            sort=sort,
            page=page,
            reservation_date=reservation_date,
            reservation_time=reservation_time,
            party_size=party_size,
            error=_build_tool_error(
                error_code="upstream_unavailable",
                message="Restaurant search failed because Tabelog returned an error response.",
                retryable=True,
                suggested_action="Validate the area or cuisine first, then retry the search.",
                detail=response.error_message,
            ),
        )

    items = _to_restaurant_outputs(response.restaurants, limit)
    status: Literal["success", "no_results"] = "success"
    if response.status == SearchStatus.NO_RESULTS:
        status = "no_results"

    return _build_search_output(
        items=items,
        limit=limit,
        meta=response.meta,
        area=area,
        keyword=keyword,
        cuisine=cuisine,
        genre_code=genre_code,
        sort=sort,
        page=page,
        reservation_date=reservation_date,
        reservation_time=reservation_time,
        party_size=party_size,
        status=status,
    )