mcp-react-frontend
Enables AI agents to analyze and scaffold React/Next.js applications enforcing Feature-Sliced Design (FSD) conventions, providing tools for project analysis, rule retrieval, and entity generation.
README
React MCP (Model Context Protocol) Frontend Server
A powerful Orchestration Core that enables AI agents to interact with React applications, enforcing Feature-Sliced Design (FSD) conventions through the Model Context Protocol.
Overview
The MCP React Frontend Server is a Model Context Protocol (MCP) implementation designed to act as an Orchestration Core and Architectural Hub for React/Next.js applications. It enforces Feature-Sliced Design (FSD) boundaries, semantic naming conventions, and project-specific constraints. The server interacts with MCP clients (like IDEs or agents) to validate code architecture, prevent structural entropy, and scaffold standardized FSD entities through deterministic rules rather than ephemeral prompts.
<div align="center"> <img src="./public/logo.png" alt="MCP React Frontend Logo" width="500" style="border-radius: 16px;" /> </div>
MCP Capabilities
Tools
-
analyze_project- Description: Analyze project files for FSD violations and naming conventions.
- Input:
files(array of strings): List of file paths to analyze (relative to project root).codeSnippets(array of objects, optional): Objects containingfileNameandcontentfor deep linter analysis.
- Output: JSON containing
status(SUCCESS/ERROR),summary(total errors/warnings),violationsarray, andrecommendationsarray. - Behavior: Delegates path analysis to
FsdAgentand code snippet analysis toLinterAgent. The combined violations are processed byRecommenderAgentto generate actionable fixes.
-
get_rules- Description: Get current FSD and naming project rules.
- Input: Empty object
{}. - Output: JSON object detailing the corporate/project rules.
- Behavior: Fetches configurations from
RulesProvider.
-
scaffold_entity- Description: Generate a standardized FSD entity structure with API, types, schema, and converters.
- Input:
name(string): The name of the entity.path(string): The target directory path (relative tosrc/entities).
- Output: Text message confirming the creation of the architecture.
- Behavior: Generates folders (
api/,types/,schema/,converters/,ui/) and boilerplate files including RTK Query services, Zod schemas, data converters, and a public API index.
Architecture
The application is built on top of the Next.js App Router and the @modelcontextprotocol/sdk.
Main Modules
mcp-server.ts: The factory that creates theMcpServerinstance, registers tools, and bridges MCP SDK with internal logic.Agents:FsdAgent: Responsible for cross-import checking and FSD semantic layer isolation constraints.LinterAgent: Checks AST or string content against naming and structural rules.RecommenderAgent: Generates mitigation steps for detected violations.
- Transports: Located in
src/app/api/mcp. Exposes bothWebStandardStreamableHTTPServerTransport(standard HTTP) andSSEServerTransport(Server-Sent Events) for different client compatibilities.
Data Flow
- Request: MCP Client connects via
/api/mcp. Next.js routes the request. - Processing: The HTTP/SSE transport translates the request into the
McpServer. For tool calls, the specific agent (FsdAgent,LinterAgent) is invoked. - Response: Analysis results are aggregated, serialized to JSON, wrapped in an MCP content block, and streamed back via the transport framework.
External Dependencies
@modelcontextprotocol/sdk: Core MCP logic.next/react: Driving the API routes and web interface.zod: Schema validation.
Usage
Clients can connect to this server over HTTP or SSE depending on their MCP transport capabilities.
Connecting to MCP Clients (e.g., Antigravity)
Add the following to your mcp_config.json manually:
1. Local Stdio (Recommended)
Fastest and most stable for development. Uses the local script directly.
{
"mcpServers": {
"mcp-react-frontend-local": {
"command": "npx",
"args": ["-y", "tsx", "scripts/mcp-stdio.ts"],
"cwd": "D://<path_to_project_root>"
}
}
}
2. Local HTTP
Connects over HTTP to a running server on localhost:3000. Requires mcp-remote.
{
"mcpServers": {
"mcp-react-frontend-http": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3000/api/mcp"]
}
}
}
3. Remote (Vercel / Render)
[!IMPORTANT] Initial connection can take up to 60 seconds due to server "warm-up" (cold start).
{
"mcpServers": {
"mcp-react-frontend-remote": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp-react-frontend.vercel.app/api/mcp"]
}
}
}
{
"mcpServers": {
"mcp-react-frontend-remote": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp-react-frontend.onrender.com/api/mcp"]
}
}
}
Supported Rules & Patterns Scope
The MCP server enforces a highly deterministic, strict architectural contract defined in src/entities/rules/config/default-rules.json. The validation scope guarantees structural integrity across the following domains:
1. Feature-Sliced Design (FSD) Topology
- Unidirectional Dependency Flow: Strictly validates import boundaries across
app→pages→widgets→features→entities→shared. - Cross-Layer Isolation: Detects and prohibits private cross-imports, enforcing mandatory barrel-export (
index.ts) usage.
2. Semantic Naming & Typing Contracts
- Pattern Enforcement: Mandates
kebab-casefor file systems. - Type Prefixing/Suffixing: Validates strict prefixes (
Ifor interfaces,Tfor types,ENUM_for enums) and DTO backend suffixes (*Backend,-backend.interface.ts). - Framework Awareness: Intelligently excludes Next.js App Router reserved files (
page,layout, etc.) and React hooks (use*) from generic naming constraints.
3. Structural Integrity & Boilerplate Constraints
- Entity Anatomy: Rejects FSD entities missing mandatory internal sub-modules (
api,types,schema,converters,ui). - File Fingerprinting: Validates extension semantics (
*.schema.ts,*.converters.ts,*.service.ts).
4. Code Quality & Safety (Linter)
- Runtime Safety: Hard bans on
console.*usage andanytypes. - TypeScript Strictness: Prohibits native TypeScript
enumusage (forcing object/const maps) and mandates strict typing.
5. UI & Design Token Constraints
- Atomic Styling: Restricts utility prefixes to authorized layout/spacing tokens (
bg-,text-,p-,m-,gap-,flex-,grid-). - Color Palette Isolation: Strictly forbids raw Tailwind color primitives (e.g.,
slate,red,blue,emerald), forcing the application to use semantic CSS variables and design tokens. - Class Merging: Mandates the
cnutility wrapper for dynamic class composition.
6. Implementation Protocol Validation
- RTK Query: Validates API code-splitting via
injectEndpoints, centralized tags, and base queries. - DTO Converters: Requires symmetric data transformation (
mapToFrontend,mapToBackend) between network boundaries and domain models. - Zod Schemas: Validates payload schema definitions against strongly typed
i18nlocalization keys. - Mocking (MSW): Ensures mock handlers are properly registered and isolated.
- Error Boundaries: Validates the presence of
ErrorBoundarywrappers andwithErrorBoundaryHOCs on dynamic or volatile UI components. - Theme Segregation: Controls the usage of
ThemeProvideranduseThemehooks for stable DOM synchronization.
Configuration
- Environment Variables:
NEXT_PUBLIC_APP_URL— Used for resolving the base application URL (defaults tohttp://localhost:3000).
- Configs: Handled internally by
RulesProvider(FSD constraints). - Secrets: Not defined in code.
Local Development
# 1. Install dependencies
npm install
# 2. Build the project (includes TypeScript compilation and Next.js build)
npm run build
# 3. Start the application
npm run dev
# Server will be available at http://localhost:3000
Requirements: Node.js 18+ (inferred from Next 14+), npm.
Limitations
- State Persistence: The MCP Server connection promises (
mcpConnectPromise) and instances are cached on the NodeJSglobalobject. This could cause issues or race conditions in serverless deployments if the instance is frozen or repeatedly cold-started. - Hardcoding: The scaffold tool implicitly hardcodes the
src/entities/prefix for generating files. - Validation Constraints: There are no advanced authentication constraints (API keys, CORS origins act transparently with
*) built into the route handlers by default. Anyone with network access to the API route can call the underlying tools.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。