Adding Current location via agument.#1
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new get_current_location tool and adds support for configuring a default location via command-line arguments or environment variables. It also renames existing tools for better consistency and updates documentation and configuration files to include JSON schemas and refined setup instructions. Review feedback suggests improving the CLI argument parsing to support standard space-separated formats, enhancing error handling within the new tool to prevent misleading success messages, and fixing tool naming inconsistencies in the configuration documentation.
| geo_result = await geocode_location(DEFAULT_LOCATION, limit=1) | ||
|
|
||
| response = { | ||
| "query": DEFAULT_LOCATION, | ||
| "results_count": len(geo_result.get("coordinates", [])), | ||
| "coordinates": geo_result.get("coordinates", []), | ||
| "message": f"Current default location: {DEFAULT_LOCATION}", | ||
| } | ||
|
|
||
| return [types.TextContent(type="text", text=json.dumps(response, indent=2))] |
There was a problem hiding this comment.
If geocode_location fails (e.g., returns an error dictionary because the location wasn't found), the current implementation swallows the error and returns an empty results list with a misleading success message. It's better to propagate the error or include it in the response.
| geo_result = await geocode_location(DEFAULT_LOCATION, limit=1) | |
| response = { | |
| "query": DEFAULT_LOCATION, | |
| "results_count": len(geo_result.get("coordinates", [])), | |
| "coordinates": geo_result.get("coordinates", []), | |
| "message": f"Current default location: {DEFAULT_LOCATION}", | |
| } | |
| return [types.TextContent(type="text", text=json.dumps(response, indent=2))] | |
| # Geocode the default location to get coordinates | |
| geo_result = await geocode_location(DEFAULT_LOCATION, limit=1) | |
| # Add a message to the result for context if successful | |
| if "error" not in geo_result: | |
| geo_result["message"] = f"Current default location: {DEFAULT_LOCATION}" | |
| return [types.TextContent(type="text", text=json.dumps(geo_result, indent=2))] |
|
|
||
| Once configured, the MCP server provides: | ||
|
|
||
| - **`mcp_geocoding_get_coordinates`**: Get latitude/longitude coordinates for any location |
There was a problem hiding this comment.
The tool name here is inconsistent with the implementation in server.py and the root README.md, which use get_coordinates without the mcp_geocoding_ prefix.
| - **`mcp_geocoding_get_coordinates`**: Get latitude/longitude coordinates for any location | |
| - **`get_coordinates`**: Get latitude/longitude coordinates for any location |
| - Uses OpenStreetMap Nominatim API (free, no API key required) No newline at end of file | ||
| - Uses OpenStreetMap Nominatim API (free, no API key required) | ||
|
|
||
| - **`mcp_geocoding_get_current_location`**: Get the current default location configured for this MCP server |
There was a problem hiding this comment.
The tool name here is inconsistent with the implementation in server.py and the root README.md, which use get_current_location without the mcp_geocoding_ prefix.
| - **`mcp_geocoding_get_current_location`**: Get the current default location configured for this MCP server | |
| - **`get_current_location`**: Get the current default location configured for this MCP server |
There was a problem hiding this comment.
duplicate maybe clean that up while we are at it.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Description
Adds Current location via argument and provides it to the LLM
everything is tested and runs with lm sudio