feat: add MCP prompt templates (find_component, implement_component)#6
feat: add MCP prompt templates (find_component, implement_component)#6
Conversation
📝 WalkthroughWalkthroughAdds two new MCP prompts ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
| - **MCP server name (alias):** `ui-layouts-mcp` | ||
| - **npm package:** `@ui-layouts/mcp` | ||
| - **Version:** `0.2.0` | ||
| - **Version:** `0.2.1-0` |
There was a problem hiding this comment.
The next release will be a minor update: v0.3.0.
There was a problem hiding this comment.
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.
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
find_componentprompt:requirements, optionaltags(comma-separated), optionalmaxCandidates(string; default"3")search_componentsmultiple times, fetchget_docssnippets for top candidates, then recommend with a structured output.implement_componentprompt:componentKeyorcomponentHref, optionalframework(default"react"), optionalincludeSourceCode(string; default"true")get_docs(snippet)get_component_metaget_source_code(when metadata provides a component name)Documentation
Behavior details
find_component.maxCandidatesis parsed from string to number with a safe default (3) to control doc fetch fan-out.Motivation
search_components,get_docs,get_component_meta,get_source_code) rather than free-form guesses.Breaking Changes
Summary by CodeRabbit
New Features
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.