MCPNEW

McpToolForm

JSON Schema → dynamic form with validation.

Available inreact

Preview

Live previewreal component

Install

TerminalBash
npx @mcp-elements/cli add mcp-tool-form

Usage

mcp-tool-form-example.tsxTSX
import { McpToolForm } from '@mcp-elements/react'

const schema = {
  type: 'object',
  properties: {
    query: { type: 'string', description: 'Search query' },
    limit: { type: 'number', default: 10, description: 'Max results' },
  },
  required: ['query'],
}

export function Example() {
  return (
    <McpToolForm
      schema={schema}
      onSubmit={(values) => console.log(values)}
      submitLabel="Search"
    />
  )
}

Props

PropTypeDefaultDescription
schema *JSONSchema7JSON Schema object that drives the form fields
onSubmit *(values: Record<string, unknown>) => voidCalled with validated form values on submit
submitLabelstring'Run'Label text for the submit button
loadingbooleanfalseDisables the form and shows a spinner on the button