# ποΈπ€ HuskyLens2MCP
Command-line AI interface for the HUSKYLENS 2 MCP Server using Python and Google Gemini.
HuskyLens2MCP connects a DFRobot HUSKYLENS 2 AI Vision Sensor directly to Google Gemini through the camera's built-in Model Context Protocol (MCP) Server.
The project provides a lightweight Python command-line client that can query the camera, switch vision algorithms, capture photos, retrieve recognition results, and combine those results with an LLM for natural-language visual reasoning.
Instead of sending the complete camera stream to Gemini, the client retrieves structured recognition data from HUSKYLENS 2 and gives that information to Gemini for interpretation.
- ποΈ Connects directly to the HUSKYLENS 2 MCP Server
- π€ Google Gemini integration
- π§ Uses
gemini-2.5-flashfor reasoning - π‘ Network communication over Wi-Fi
- π MCP over SSE and JSON-RPC
- π Lists available HUSKYLENS algorithms
- π Shows the currently active algorithm
- π Switches vision algorithms from the terminal
- π Retrieves real-time recognition results
- π¬ Ask natural-language questions about what the sensor sees
- π Generate natural-language descriptions of recognition data
- πΈ Trigger photo capture remotely
- π Pure Python client
- π MIT licensed
MCP β Model Context Protocol provides a standardized way for AI applications to interact with external tools and data sources.
HUSKYLENS 2 includes an MCP Server that exposes parts of the camera as callable tools.
Instead of building a custom API for every vision feature, an external program can interact with operations such as:
get_recognition_result
manage_applications
multimedia_control
task_scheduler
This project implements a Python client for that server and adds Gemini as a reasoning layer.
ββββββββββββββββββββββββββββββββ
β HUSKYLENS 2 β
β β
β β’ Object Recognition β
β β’ Face Recognition β
β β’ Object Tracking β
β β’ OCR β
β β’ Pose Recognition β
β β’ Custom models β
β β’ Other vision algorithms β
β β
β MCP Server β
ββββββββββββββββ¬ββββββββββββββββ
β
β Wi-Fi
β SSE + JSON-RPC
βΌ
ββββββββββββββββββββββββββββββββ
β huskyMcpChat.py β
β β
β β’ MCP client β
β β’ Algorithm control β
β β’ Recognition retrieval β
β β’ Photo commands β
β β’ CLI β
ββββββββββββββββ¬ββββββββββββββββ
β
β Recognition JSON
βΌ
ββββββββββββββββββββββββββββββββ
β Google Gemini β
β gemini-2.5-flash β
β β
β β’ Interpretation β
β β’ Natural-language answers β
β β’ Contextual reasoning β
ββββββββββββββββββββββββββββββββ
This architecture combines two different types of AI:
HUSKYLENS 2
Specialized computer vision
β
Detects what is in the scene
Gemini
Language + reasoning
β
Interprets what the detections mean
For a command such as:
ask Is there anything dangerous on the table?
the workflow is:
Camera
β
HUSKYLENS recognition algorithm
β
Structured recognition data
β
Python MCP client
β
Gemini
β
Natural-language answer
The Python client explicitly instructs Gemini to answer based on the sensor evidence provided to it.
This makes it possible to transform low-level recognition output into more useful questions such as:
ask Is there a person?
ask What objects are visible?
ask Is the person standing near the table?
The quality of the answer ultimately depends on the recognition data returned by the currently selected HUSKYLENS algorithm.
- DFRobot HUSKYLENS 2
- Computer capable of running Python
- Wi-Fi network accessible by both devices
HUSKYLENS 2 product information:
Official documentation:
- Python 3
aiohttpgoogle-genai- Google Gemini API key
Install the Python dependencies:
pip install aiohttp google-genaiCreate a Gemini API key using Google AI Studio:
The current script expects the key in:
GEMINI_API_KEY = ""Example:
GEMINI_API_KEY = "YOUR_API_KEY"π Do not publish or commit a real API key to a public repository.
The original project was developed using MCP-capable HUSKYLENS 2 firmware starting with version:
1.1.6
The latest firmware and update instructions are available from:
HUSKYLENS 2 Firmware / Documentation
DFRobot community reports later identified MCP problems with firmware 1.2.1, including algorithm-switching and recognition-data errors.
DFRobot subsequently stated that firmware 1.2.2 fixes MCP instability issues and adds additional tools.
If you encounter unexpected MCP errors, update to a current firmware release and consult the latest DFRobot documentation.
On the camera:
- Open Settings.
- Configure Wi-Fi.
- Connect to your local network.
- Enable the MCP Server.
Official MCP documentation:
HUSKYLENS 2 MCP Server β DFRobot Wiki
When MCP is enabled, HUSKYLENS displays the server address.
It typically uses port:
3000
For example:
http://192.168.1.100:3000
Clone the repository:
git clone https://github.com/ronibandini/HuskyLens2MCP.git
cd HuskyLens2MCPInstall dependencies:
pip install aiohttp google-genaiOpen:
huskyMcpChat.py
and configure:
GEMINI_API_KEY = "YOUR_GEMINI_API_KEY"
SERVER_URL = "http://192.168.1.100:3000"Replace the IP address with the address displayed by your HUSKYLENS 2.
Then run:
python huskyMcpChat.pyAfter connecting successfully, the client displays:
========================================
Huskylens2 MCP Command Line
Roni Bandini 11/2025
MIT License
========================================
1. list : List algorithms
2. current : Show active algorithm
3. switch <Algorithm> : Switch algorithm
4. ask <Question> : Ask AI about the view
5. see : General AI description
6. photo : Take photo
7. exit : Quit
----------------------------------------
Retrieve the algorithms available on HUSKYLENS 2:
list
Internally this calls:
manage_applications
operation: application_list
Show the active vision algorithm:
current
Internally:
manage_applications
operation: current_application
Switch the active computer-vision algorithm:
switch FaceRecognition
Internally:
manage_applications
operation: switch_application
The exact algorithm name should match one returned by:
list
Ask Gemini a question using the current HUSKYLENS recognition results as context:
ask Is there a person?
Another example:
ask Is there anything dangerous on the table?
The client first calls:
get_recognition_result
operation: get_result
and then passes the returned recognition data together with the question to Gemini.
Generate a short natural-language description of the current recognition result:
see
or:
look
The script retrieves the current sensor data and asks Gemini to briefly describe what is visible.
Trigger a photo capture:
photo
or:
snap
Internally:
multimedia_control
operation: take_photo
The image is stored in the HUSKYLENS internal memory.
Close the MCP connection and terminate the client:
exit
or:
quit
The project does not require a third-party MCP client library.
huskyMcpChat.py implements the required communication directly using aiohttp.
It opens the HUSKYLENS SSE endpoint:
/sse
The server responds with a session-specific message endpoint similar to:
/message?session_id=...
Requests are then sent as JSON-RPC messages.
The client initializes the MCP session using protocol version:
2024-11-05
with:
{
"method": "initialize",
"clientInfo": {
"name": "HuskyLens-Py",
"version": "1.2.0"
}
}This makes the repository useful not only as a HUSKYLENS example but also as a compact reference for implementing a simple MCP client manually.
The original project documents four important MCP tools.
Retrieves real-time recognition data.
Typical operation:
get_result
Useful for:
- object recognition
- face recognition
- visual reasoning
- natural-language descriptions
Controls the computer-vision algorithms running on HUSKYLENS.
Operations documented by the project include:
current_application
application_list
switch_application
Controls multimedia functions.
The project currently uses:
take_photo
HUSKYLENS also exposes scheduled or triggered tasks.
Examples include concepts such as:
Take a picture after 3 seconds
or:
Take a picture when you see a keyboard
The current command-line interface does not expose a dedicated scheduler command, but the MCP tool is documented by the project and provides an interesting path for future development.
HUSKYLENS firmware has continued evolving since this project's original release, so newer versions may expose additional MCP capabilities.
The project uses:
gemini-2.5-flash
through Google's current Python SDK:
from google import genaiThe basic flow is:
self.client.models.generate_content(
model='gemini-2.5-flash',
contents=prompt
)For ask, Gemini receives:
SENSOR DATA
+
USER QUESTION
+
INSTRUCTIONS
For see, it receives:
SENSOR DATA
+
DESCRIPTION INSTRUCTIONS
The prompt tells Gemini to rely on the supplied sensor evidence and to mention cases where the data is empty or confidence is low.
HuskyLens2MCP/
βββ LICENSE
βββ README.md
βββ huskyMcpChat.py
Contains:
- asynchronous HTTP communication
- SSE listener
- JSON-RPC handling
- MCP session initialization
- MCP tool calls
- recognition-data extraction
- Gemini API integration
- interactive command-line interface
-
πΌοΈ Multimodal image reasoning β retrieve captured images and optionally send the actual frame to a multimodal model alongside HUSKYLENS structured recognition data.
-
β° Expose
task_schedulerin the CLI β add commands for conditional and scheduled actions such as capturing a photo when a particular object or person is recognized. -
π Externalize configuration β load the Gemini key and MCP address from environment variables or a
.envfile instead of storing credentials inside the Python source.
HuskyLens2MCP has been documented, indexed, and discussed outside GitHub.
HuskyLens 2 Model Context Protocol (MCP)
The complete Hackster tutorial explains the motivation for connecting the HUSKYLENS 2 MCP Server directly to Gemini from Python.
It covers:
- firmware setup
- MCP activation
- Gemini configuration
- Python client setup
- algorithm switching
- photo capture
- visual queries
- combined LLM reasoning
- HUSKYLENS MCP tools
The Hackster project links directly to this GitHub repository.
Huskylens2 MCP with Python and Gemini LLM
DFRobot's Maker Community hosts a complete version of the project tutorial.
It covers the HUSKYLENS 2 firmware setup, Gemini API configuration, MCP Server, command-line client, visual reasoning examples, and MCP tools.
The article explicitly links to:
github.com/ronibandini/HuskyLens2MCP
HUSKYLENS Projects β DFRobot Maker Community
The project is also indexed in DFRobot's HUSKYLENS project collection as:
Huskylens2 MCP with Python and Gemini LLM
LΓnea de comandos para el MCP de la cΓ‘mara Huskylens2
Spanish-language article about interacting with the HUSKYLENS 2 MCP Server through a command-line Python client and Gemini.
This is also the article linked from the GitHub repository's About section.
- HUSKYLENS 2 Official Wiki
- HUSKYLENS 2 MCP Server Guide
- HUSKYLENS 2 Product Page
- Google AI Studio
- Model Context Protocol
Other projects by Roni Bandini involving AI interfaces, computer vision, LLMs, and physical computing.
Run Google Gemini directly from a jailbroken Kindle Paperwhite.
Another minimalist command-line interface for Gemini, implemented using BusyBox, Bash, KTerm, curl, and the Gemini API.
github.com/ronibandini/GeminiForKindle
Punched-card recognition with computer vision, Edge Impulse, and LattePanda IOTA.
Like HuskyLens2MCP, this project combines a dedicated computer-vision system with a lightweight software layer for interpreting physical objects.
github.com/ronibandini/PunchedCards
Physical buttons and a dedicated screen for n8n workflows and AI agents.
Another experiment in moving AI interactions away from conventional desktop interfaces and into dedicated physical hardware.
github.com/ronibandini/n8nTerminal
The current implementation stores the Gemini API key directly in the Python script:
GEMINI_API_KEY = ""For private experiments this is simple, but avoid committing a configured key to GitHub.
For a more robust implementation, use:
- environment variables
.envfiles excluded through.gitignore- an operating-system credential store
The HUSKYLENS MCP Server should also be treated as a network-accessible control interface. Use it on networks you trust and review the current DFRobot security guidance before exposing the service beyond a local LAN.
HuskyLens2MCP is released under the MIT License.
See LICENSE for details.
Roni Bandini
Maker, AI developer, electronic artist and writer.
- π GitHub: @ronibandini
- πΈ Instagram: @ronibandini
- π¦ X: @RoniBandini
- βοΈ Medium: bandini.medium.com
- π οΈ Hackster: Roni Bandini
Contributions, forks, MCP experiments, alternative LLM integrations, and new HUSKYLENS tools are welcome.