Configuration
Frontend Configuration
ChatComponent Props
The ChatComponent
accepts the following props:
typescript
interface ChatComponentProps {
name: string; // Component name to render
props: any; // Props to pass to the component
fallback?: ReactNode; // Loading state component
errorFallback?: ReactNode; // Error state component
}
Example Usage
Backend Configuration
MCP Host Configuration
The MCP Host can be configured with the following options:
typescript
interface MCPHostConfig {
mcpServer: {
configPath: string; // Path to mcp_servers.config.json
};
mcpComponent: {
configPath: string; // Path to mcp_components.config.json
};
watch?: boolean; // Enable file watching for config changes
}
Server Configuration File
The mcp_servers.config.json
file should follow this structure:
json
{
"servers": [
{
"name": "cart-server",
"type": "stdio",
"command": "node ./servers/cart-server.js",
"env": {
"NODE_ENV": "development"
}
}
]
}
Component Configuration File
The mcp_components.config.json
file is automatically generated by the Vite plugin, but you can also create it manually:
json
[
{
"name": "Cart",
"propertySchema": {
"type": "object",
"properties": {
"books": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"title": { "type": "string" },
"author": { "type": "string" },
"cover": { "type": "string" },
"price": { "type": "number" },
"count": { "type": "number" }
}
}
}
}
},
"description": "Display shopping cart information",
"serverName": "cart-server"
}
]
Build Tool Configuration
Vite Plugin Configuration
The Vite plugin can be configured with the following options:
typescript
interface MCPCompConfig {
pushConfig?: {
serverUrl: string; // URL of the config server
projectId: string; // Project identifier
env: string; // Environment (development/production)
};
outputPath?: string; // Custom output path for config files
}
Example Configuration
typescript
// vite.config.ts
import { defineConfig } from 'vite'
import { MCPComp } from 'vite-plugin-mcp'
export default defineConfig({
plugins: [
MCPComp({
pushConfig: {
serverUrl: 'http://localhost:3000/api/config',
projectId: 'my-project',
env: process.env.NODE_ENV
},
outputPath: './dist/mcp'
})
]
})
Environment Variables
The following environment variables can be used to configure the system:
MCP_SERVER_URL
: URL of the MCP serverMCP_PROJECT_ID
: Project identifierMCP_ENV
: Environment (development/production)MCP_WATCH
: Enable file watching (true/false)
Security Considerations
- Always validate component props on the server side
- Use HTTPS for all server communications
- Implement proper authentication and authorization
- Sanitize all user inputs
- Keep dependencies up to date