Skip to content

feat: add MCP prompt templates (find_component, implement_component)#6

Merged
naymurdev merged 5 commits intomainfrom
feature/prompts
Jan 26, 2026
Merged

feat: add MCP prompt templates (find_component, implement_component)#6
naymurdev merged 5 commits intomainfrom
feature/prompts

Conversation

@Yeom-JinHo
Copy link
Collaborator

@Yeom-JinHo Yeom-JinHo commented Jan 18, 2026

Description

This PR introduces reusable MCP prompt templates to help AI assistants orchestrate existing tools in a consistent, reliable way.

  • find_component: Finds the best ui-layouts component(s) based on requirements (and optional tags), by performing multi-query searches and comparing top candidates via docs snippets.
  • implement_component: Produces a step-by-step implementation guide for a specific component using docs, metadata, and optionally source code.

Changes

  • Prompts

    • Added find_component prompt:
      • Inputs: requirements, optional tags (comma-separated), optional maxCandidates (string; default "3")
      • Strategy guidance: generate 3–6 short queries with synonyms, call search_components multiple times, fetch get_docs snippets for top candidates, then recommend with a structured output.
    • Added implement_component prompt:
      • Inputs: componentKey or componentHref, optional framework (default "react"), optional includeSourceCode (string; default "true")
      • Resolves the target component from registry and guides the assistant to call:
        • get_docs (snippet)
        • get_component_meta
        • optionally get_source_code (when metadata provides a component name)
  • Documentation

    • Updated README prompt section:
      • Added parameter descriptions
      • Explained what each prompt does, strategy, and expected output format
  • Behavior details

    • find_component.maxCandidates is parsed from string to number with a safe default (3) to control doc fetch fan-out.
    • Prompts explicitly instruct assistants to use tools and avoid guessing.

Motivation

  • Provide an opinionated, repeatable workflow for common tasks:
    • “Which component should I use for X?”
    • “How do I implement this component in my stack?”
  • Reduce hallucination by requiring tool calls (search_components, get_docs, get_component_meta, get_source_code) rather than free-form guesses.
  • Improve developer experience by producing structured, actionable outputs (recommendations + exact next tool calls).

Breaking Changes

  • None.

Summary by CodeRabbit

  • New Features

    • Added find_component prompt for discovering UI components with customizable search criteria and recommendations
    • Added implement_component prompt for generating step-by-step implementation guides with framework and styling guidance
    • Extended server to surface AI-assisted prompt workflows
  • Chores

    • Bumped server version to 0.2.1-0
  • Documentation

    • Added a "Prompts" section in README with reusable templates and usage guidance

✏️ Tip: You can customize this high-level summary in your review settings.

@Yeom-JinHo Yeom-JinHo self-assigned this Jan 18, 2026
@Yeom-JinHo Yeom-JinHo requested a review from naymurdev January 18, 2026 09:04
@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

Adds two new MCP prompts (find_component, implement_component), documents them in README, registers them in src/index.ts, and bumps server version to 0.2.1-0. The server registration appears duplicated in the diff, creating two identical prompt entries.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added a "Prompts" section describing two reusable MCP templates (find_component, implement_component) with parameters, behavior, and strategy; minor formatting and separator updates; server version updated to 0.2.1-0.
Server Prompt Registration
src/index.ts
Added prompts: {} capability to McpServer init and registered find_component and implement_component prompts with Zod input schemas, defaults, and async handlers that return user-role instruction messages. Attention: the diff shows duplicated registrations for each prompt (two identical inserts), which may create duplicate prompt entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • naymurdev

Poem

🐰 I hopped through README, bright and spry,
Two prompts I planted, under server sky.
Find the parts, then build with care—
Duplicates hiding? I'll sniff them there. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding two new MCP prompt templates (find_component and implement_component) to the codebase, which aligns with the changes in both README.md and src/index.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- **MCP server name (alias):** `ui-layouts-mcp`
- **npm package:** `@ui-layouts/mcp`
- **Version:** `0.2.0`
- **Version:** `0.2.1-0`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next release will be a minor update: v0.3.0.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/index.ts`:
- Around line 318-375: The maxCandidates parsing in the server.prompt handler
currently does parseInt(maxCandidates, 10) || 3 but does not enforce the
documented 1–10 range; clamp the resulting maxCandidatesNum to be between 1 and
10 (e.g. parseInt(maxCandidates,10) with fallback to 3, then apply Math.max(1,
Math.min(10, value))) wherever maxCandidatesNum is computed inside the
"find_component" prompt handler so downstream calls that use maxCandidatesNum
cannot exceed the allowed range.
- Around line 388-497: The prompt mixes includeSourceCode strings and guidance
causing a contradiction: normalize includeSourceCode to a boolean early (e.g.
parse includeSourceCode = includeSourceCode === "true") and then update the
instructions array (the template built in the async handler and the final
sentence "Make the guide... Include real code examples from the source when
available.") to be conditional based on that boolean—when false, remove/replace
any sentences that demand source examples and ensure the `## Required Tool
Calls` section already conditionally skips `get_source_code` (preserve that
logic in get_source_code call) so all source-related guidance and the final
sentence are omitted or changed to say "Use docs snippets only" when
includeSourceCode is false.

@naymurdev naymurdev merged commit 07fe10c into main Jan 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants