Bi dur, some info is missing! Let me generate UI to gather the missing pieces.
Dynamic form generation for AI agents via Model Context Protocol (MCP).
Agent: "I need api_key, project_name from the user"
↓
MCP Server creates a form → User fills it in browser → Data returns to agent
from agents import Agent, Runner
from agents.mcp import MCPServerSse
async def main():
async with MCPServerSse(
params={
"url": "https://gen-ui-mcp-server.onrender.com/sse",
"headers": {"X-OpenAI-API-Key": "sk-..."},
},
client_session_timeout_seconds=300,
) as mcp_server:
agent = Agent(
name="My Agent",
instructions="Use collect_user_input to gather info from user.",
mcp_servers=[mcp_server],
)
result = await Runner.run(agent, "Collect user's name and email")cd docker
docker-compose up -d
# MCP Server: http://localhost:8080
# Form Server: http://localhost:9110Then test with MCP Inspector:
npx @modelcontextprotocol/inspectorSet URL to http://localhost:8080/sse in browser UI. Add a new Custom Header named X-OpenAI-API-Key. Enter your OpenAI API key in the Value field.
npx @modelcontextprotocol/inspector sse https://gen-ui-mcp-server.onrender.com/sse --header "X-OpenAI-API-Key: sk-..."Then in the browser UI:
- Set URL to:
https://gen-ui-mcp-server.onrender.com/sse - Go to Tools tab
- Run
collect_user_inputwith test input - Check Server Notifications for form URL
python examples/mcp_sse_example.pygit clone https://github.com/ogulcanakca/bidur.git
cd bidur
pip install -r requirements.txt
export OPENAI_API_KEY=sk-...| Parameter | Type | Description |
|---|---|---|
missing_fields |
list[str] |
Field names to collect (e.g., ["username", "email"]) |
context |
str |
Optional context for better form generation |
timeout_seconds |
int |
Max wait time (default: 300) |
Returns:
{
"form_url": "https://...",
"message": "User successfully submitted the form",
"data": {"username": "john", "email": "john@example.com"}
}┌─────────────┐ SSE ┌─────────────┐ HTTP ┌─────────────┐
│ Agent │◄────────────►│ MCP Server │◄────────────►│ Form Server │
│ (Your App) │ │ Port 8080 │ │ Port 9110 │
└─────────────┘ └─────────────┘ └─────────────┘
│ │
Tool Handler HTML/JS Form
API Key Mgmt Schema Gen
gen-ui-mcp/
├── src/gen_ui/
│ ├── mcp_server/ # MCP Server implementation
│ │ ├── server.py # SSE transport, tool routing
│ │ └── tools.py # collect_user_input tool
│ ├── agents/ # Form schema generation
│ └── tools/ # Standalone tool (non-MCP)
├── ui/html/
│ ├── server.py # Form Server HTTP API
│ └── index.html # Form UI
├── docker/
│ ├── Dockerfile.mcp
│ ├── Dockerfile.form
│ └── docker-compose.yml
├── examples/
│ └── mcp_sse_example.py # SSE connection example
└── run_mcp_server.py # Entry point (stdio/sse)
Research in Progress: VS Code, Cursor, and Claude Desktop clients do not currently display log notifications during tool execution. This means the form URL is not visible until after form submission. Investigation is ongoing for alternative approaches.
This project supports Guardrails and Tracing features from the OpenAI Agents SDK.
Built-in Guardrails:
| Guardrail | Type | Description |
|---|---|---|
safety_guardrail |
Input | Validates field names, checks for injection patterns |
llm_field_validation_guardrail |
Input | LLM-based semantic validation for suspicious field names |
schema_format_guardrail |
Output | Validates JSON Schema structure and property definitions |
