--- title: Edge Impulse MCP Demo emoji: 🧠 colorFrom: blue colorTo: green sdk: gradio sdk_version: 5.49.1 app_file: app.py pinned: false license: apache-2.0 short_description: Edge Impulse MCP tools and agent chat. tags: - mcp-server-track - mcp - edge-impulse - gradio --- # Edge Impulse MCP Demo Space This Hugging Face Space exposes a single-page Edge Impulse agent UI through Gradio MCP support. Users set an Edge Impulse API key or JWT once, then use the Space-hosted Qwen conversation or the compact tool console. It is intended for demos, developer showcases, and early MCP experimentation. It is not the production remote MCP connector. ## Page Layout - Connection and model settings: API key/JWT, default project ID, action permission, and conversation model. - Conversation: chat with the Space-hosted Qwen agent about projects, jobs, logs, deployment targets, and guarded actions. - Tool console: explicit tool runner for debugging and repeatable calls. ## MCP/API Tools - `chat_with_edge_impulse`: single-turn conversational agent control plane over the Edge Impulse tools. - `run_tool_console`: explicit tool runner with structured inputs. - `qwen_status`: checks the Space-hosted Qwen dependency and model-load status. The underlying tool runner can list projects, inspect project info, list deployment targets, list active jobs, get job status/logs, start retrain/evaluate/generate-features/train/build jobs, and cancel jobs. Action tools require `confirm=true` so a user or agent has to explicitly opt in before the Space starts or changes work in Edge Impulse. ## Agent Chat The conversation area is a lightweight control plane over the tools. By default, the agentic interaction happens inside this Space using `Qwen/Qwen2.5-0.5B-Instruct`; users do not need Claude, ChatGPT, or another external agent to try it. General chat works before entering an Edge Impulse credential. Edge Impulse tool calls still require an API key, JWT, or configured Space secret. The chat also supports slash-callable skills inspired by the Edge Impulse Agent Skill tutorial: - `/skills`: list available slash skills. - `/docs`: link to the full Edge Impulse skill tutorial and docs index. - `/edge-impulse`: general Studio control-plane skill. - `/project-info`: inspect project metadata and deployment targets. - `/monitor-job`: check job status and logs. - `/train-ei-model`: retrain, evaluate, generate features, or train Keras blocks. - `/deploy-impulse`: build deployment artifacts. The full tutorial for creating and installing the persistent `edge-impulse` Agent Skill is here: https://docs.edgeimpulse.com/tutorials/topics/ai-agents/create-edge-impulse-skill It routes common requests such as: - "Show project 69300" - "List active jobs for project 69300" - "Get logs for job 123 in project 69300" - "Retrain project 69300" - "Generate features for project 69300 dsp 12" - "Train Keras learn block 34 for project 69300 with 40 cycles and learning rate 0.005" - "/edge-impulse list projects" - "/monitor-job project 69300 job 123 logs" The chat layer does deterministic tool routing first. The Space-hosted Qwen model is then used to summarize the result and explain next steps. This keeps tool execution predictable even when using a very small model. Supported conversation modes: - `Space-hosted Qwen 2.5 0.5B`: default. Runs `Qwen/Qwen2.5-0.5B-Instruct` inside the Space when `ENABLE_LOCAL_QWEN=true`. The Space starts loading the model in the background by default, so the page can render while Qwen warms up. - `External OpenAI-compatible API`: optional bring-your-own LLM mode for OpenAI, a vLLM server, Hugging Face router, Together, Groq, or another compatible endpoint. - `No LLM`: returns the selected tool and raw result without model summarization. External agents can also connect to the Gradio MCP endpoint and call `chat_with_edge_impulse` or `run_tool_console` directly. That is optional; the built-in demo is designed to work from inside the Space. Use the "Check Space-hosted Qwen" button to inspect whether dependencies are installed and whether the model has loaded. Enable "Force model load" to trigger the first model download/load explicitly. You can later replace the default local model with an Edge Impulse adapter/RAG-trained Qwen model by setting `CHAT_MODEL` to that model ID. ## Credentials Users can try the Space by selecting a credential type once in the connection panel and pasting either: - an Edge Impulse API key, or - an Edge Impulse JWT token. To get a JWT token, use the Edge Impulse Studio login API docs: https://docs.edgeimpulse.com/apis/studio/login/get-jwt-token?playground=open To limit what the MCP demo can access, open a specific Edge Impulse project and create an API key for that project instead of using a broad JWT. The credential is reused by the page for chat and tool-console requests. It is not stored by the app. ## Optional Space Secrets For a shared demo account, the Space owner can configure one of these in the Hugging Face Space settings: - `EI_API_KEY`: Edge Impulse API key. - `EI_JWT_TOKEN`: Edge Impulse JWT token. Optional settings: - `EI_HOST`: defaults to `https://studio.edgeimpulse.com/v1`. - `EI_REQUEST_TIMEOUT_SECONDS`: defaults to `20`. - `EI_MAX_RESPONSE_CHARS`: defaults to `12000`. - `CHAT_MODEL`: defaults to `Qwen/Qwen2.5-0.5B-Instruct`. - `ENABLE_LOCAL_QWEN`: defaults to `true`. Set to `false` to disable local model loading. - `PRELOAD_QWEN`: defaults to `true`. Set to `false` only if you want fully lazy model loading. - `LOCAL_LLM_MAX_NEW_TOKENS`: defaults to `220`. Do not hard-code credentials in this repository. Use the page credential field or Hugging Face Space Secrets. ## Local Run ```bash cd hf-space-edge-impulse-mcp python -m venv .venv . .venv/bin/activate pip install -r requirements.txt EI_API_KEY=ei_... python app.py ``` The app calls `demo.launch(mcp_server=True)`, so Hugging Face should display the MCP badge after the Space is deployed. ## Scope This Space is intended as a public "try it now" demo and developer showcase. For a production connector, use a hosted remote MCP server with OAuth, per-user credential mapping, audit logs, rate limits, confirmation policies for risky actions, and a larger reviewed tool set.