sjtu_vision
Analyze images by submitting a prompt and an image via URL or local path. The vision model returns understanding of the image content.
Instructions
Run an image understanding task against the default vision model.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | ||
| image_path | No | ||
| image_url | No | ||
| model | No | ||
| system_prompt | No | ||
| temperature | No | ||
| max_tokens | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/sjtu_mcp/server.py:87-108 (handler)The `sjtu_vision` tool handler: an async function that runs an image understanding task against the default vision model using the SjtuClient.
async def sjtu_vision( prompt: str, image_path: str | None = None, image_url: str | None = None, model: str | None = None, system_prompt: str | None = None, temperature: float = 0.2, max_tokens: int | None = None, ) -> str: """Run an image understanding task against the default vision model.""" response = await client.chat( model=model or settings.default_vision_model, messages=_build_vision_messages( prompt, image_path=image_path, image_url=image_url, system_prompt=system_prompt, ), temperature=temperature, max_tokens=max_tokens, ) return _extract_text(response) - src/sjtu_mcp/server.py:88-95 (schema)Input parameters (schema) for sjtu_vision: prompt, image_path, image_url, model, system_prompt, temperature, max_tokens.
prompt: str, image_path: str | None = None, image_url: str | None = None, model: str | None = None, system_prompt: str | None = None, temperature: float = 0.2, max_tokens: int | None = None, ) -> str: - src/sjtu_mcp/server.py:86-87 (registration)The `@mcp.tool()` decorator registers sjtu_vision as an MCP tool on the FastMCP server.
@mcp.tool() async def sjtu_vision( - src/sjtu_mcp/server.py:40-60 (helper)`_build_vision_messages` helper that constructs the messages payload including the image (from path or URL) and optional system prompt.
def _build_vision_messages( prompt: str, *, image_path: str | None, image_url: str | None, system_prompt: str | None, ) -> list[dict[str, Any]]: if not image_path and not image_url: raise ValueError("Provide either image_path or image_url.") image_source = image_url or image_path_to_data_url(image_path or "") user_content = [ {"type": "text", "text": prompt}, {"type": "image_url", "image_url": {"url": image_source}}, ] messages: list[dict[str, Any]] = [] if system_prompt: messages.append({"role": "system", "content": system_prompt}) messages.append({"role": "user", "content": user_content}) return messages