Skip to main content
Glama

maps

Search locations, get directions, and manage guides with Apple Maps integration. Save favorites, pin addresses, and create custom guides for efficient navigation.

Instructions

Search locations, manage guides, save favorites, and get directions using Apple Maps

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressNoAddress of the location (required for save, pin, addToGuide)
fromAddressNoStarting address for directions (required for directions)
guideNameNoName of the guide (required for createGuide and addToGuide)
limitNoMaximum number of results to return (optional for search)
nameNoName of the location (required for save and pin)
operationYesOperation to perform with Maps
queryNoSearch query for locations (required for search)
toAddressNoDestination address for directions (required for directions)
transportTypeNoType of transport to use (optional for directions)

Implementation Reference

  • The main MCP tool handler for 'maps' tool. Loads the maps module dynamically and dispatches to specific operations like search, save, directions, etc., based on input parameters.
    case "maps": {
    	if (!isMapsArgs(args)) {
    		throw new Error("Invalid arguments for maps tool");
    	}
    
    	try {
    		const mapsModule = await loadModule("maps");
    		const { operation } = args;
    
    		switch (operation) {
    			case "search": {
    				const { query, limit } = args;
    				if (!query) {
    					throw new Error(
    						"Search query is required for search operation",
    					);
    				}
    
    				const result = await mapsModule.searchLocations(query, limit);
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.success
    								? `${result.message}\n\n${result.locations
    										.map(
    											(location) =>
    												`Name: ${location.name}\n` +
    												`Address: ${location.address}\n` +
    												`${location.latitude && location.longitude ? `Coordinates: ${location.latitude}, ${location.longitude}\n` : ""}`,
    										)
    										.join("\n\n")}`
    								: `${result.message}`,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			case "save": {
    				const { name, address } = args;
    				if (!name || !address) {
    					throw new Error(
    						"Name and address are required for save operation",
    					);
    				}
    
    				const result = await mapsModule.saveLocation(name, address);
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.message,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			case "pin": {
    				const { name, address } = args;
    				if (!name || !address) {
    					throw new Error(
    						"Name and address are required for pin operation",
    					);
    				}
    
    				const result = await mapsModule.dropPin(name, address);
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.message,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			case "directions": {
    				const { fromAddress, toAddress, transportType } = args;
    				if (!fromAddress || !toAddress) {
    					throw new Error(
    						"From and to addresses are required for directions operation",
    					);
    				}
    
    				const result = await mapsModule.getDirections(
    					fromAddress,
    					toAddress,
    					transportType as "driving" | "walking" | "transit",
    				);
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.message,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			case "listGuides": {
    				const result = await mapsModule.listGuides();
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.message,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			case "addToGuide": {
    				const { address, guideName } = args;
    				if (!address || !guideName) {
    					throw new Error(
    						"Address and guideName are required for addToGuide operation",
    					);
    				}
    
    				const result = await mapsModule.addToGuide(address, guideName);
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.message,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			case "createGuide": {
    				const { guideName } = args;
    				if (!guideName) {
    					throw new Error(
    						"Guide name is required for createGuide operation",
    					);
    				}
    
    				const result = await mapsModule.createGuide(guideName);
    
    				return {
    					content: [
    						{
    							type: "text",
    							text: result.message,
    						},
    					],
    					isError: !result.success,
    				};
    			}
    
    			default:
    				throw new Error(`Unknown maps operation: ${operation}`);
    		}
    	} catch (error) {
    		const errorMessage = error instanceof Error ? error.message : String(error);
    		return {
    			content: [
    				{
    					type: "text",
    					text: errorMessage.includes("access") ? errorMessage : `Error in maps tool: ${errorMessage}`,
    				},
    			],
    			isError: true,
    		};
    	}
    }
  • Input schema and metadata definition for the 'maps' MCP tool, including all supported operations and parameters.
    const MAPS_TOOL: Tool = {
      name: "maps",
      description: "Search locations, manage guides, save favorites, and get directions using Apple Maps",
      inputSchema: {
        type: "object",
        properties: {
          operation: {
            type: "string",
            description: "Operation to perform with Maps",
            enum: ["search", "save", "directions", "pin", "listGuides", "addToGuide", "createGuide"]
          },
          query: {
            type: "string",
            description: "Search query for locations (required for search)"
          },
          limit: {
            type: "number",
            description: "Maximum number of results to return (optional for search)"
          },
          name: {
            type: "string",
            description: "Name of the location (required for save and pin)"
          },
          address: {
            type: "string",
            description: "Address of the location (required for save, pin, addToGuide)"
          },
          fromAddress: {
            type: "string",
            description: "Starting address for directions (required for directions)"
          },
          toAddress: {
            type: "string",
            description: "Destination address for directions (required for directions)"
          },
          transportType: {
            type: "string",
            description: "Type of transport to use (optional for directions)",
            enum: ["driving", "walking", "transit"]
          },
          guideName: {
            type: "string",
            description: "Name of the guide (required for createGuide and addToGuide)"
          }
        },
        required: ["operation"]
      }
    };
  • tools.ts:294-296 (registration)
    Registration of the 'maps' tool as part of the exported tools array used by the MCP server for tool listing.
    const tools = [CONTACTS_TOOL, NOTES_TOOL, MESSAGES_TOOL, MAIL_TOOL, REMINDERS_TOOL, CALENDAR_TOOL, MAPS_TOOL];
    
    export default tools;
  • Core implementation module exporting all handler functions for Maps app interactions via AppleScript/JXA, including search, save, directions, etc.
    const maps = {
        searchLocations,
        saveLocation,
        getDirections,
        dropPin,
        listGuides,
        addToGuide,
        createGuide,
        requestMapsAccess
    };
    
    export default maps;
  • Example helper: searchLocations function - primary implementation for searching locations in Apple Maps app using JXA scripting.
    async function searchLocations(query: string, limit: number = 5): Promise<SearchResult> {
        try {
            const accessResult = await requestMapsAccess();
            if (!accessResult.hasAccess) {
                return {
                    success: false,
                    locations: [],
                    message: accessResult.message
                };
            }
    
            console.error(`searchLocations - Searching for: "${query}"`);
    
            // First try to use the Maps search function
            const locations = await run((args: { query: string, limit: number }) => {
                try {
                    const Maps = Application("Maps");
                    
                    // Launch Maps and search (this is needed for search to work properly)
                    Maps.activate();
                    
                    // Execute search using the URL scheme which is more reliable
                    Maps.activate();
                    const encodedQuery = encodeURIComponent(args.query);
                    Maps.openLocation(`maps://?q=${encodedQuery}`);
                    
                    // For backward compatibility also try the standard search method
                    try {
                        Maps.search(args.query);
                    } catch (e) {
                        // Ignore error if search is not supported
                    }
                    
                    // Wait a bit for search results to populate
                    delay(2); // 2 seconds
                    
                    // Try to get search results, if supported by the version of Maps
                    const locations: MapLocation[] = [];
                    
                    try {
                        // Different versions of Maps have different ways to access results
                        // We'll need to use a different method for each version
                        
                        // Approach 1: Try to get locations directly 
                        // (this works on some versions of macOS)
                        const selectedLocation = Maps.selectedLocation();
                        if (selectedLocation) {
                            // If we have a selected location, use it
                            const location: MapLocation = {
                                id: `loc-${Date.now()}-${Math.random()}`,
                                name: selectedLocation.name() || args.query,
                                address: selectedLocation.formattedAddress() || "Address not available",
                                latitude: selectedLocation.latitude(),
                                longitude: selectedLocation.longitude(),
                                category: selectedLocation.category ? selectedLocation.category() : null,
                                isFavorite: false
                            };
                            locations.push(location);
                        } else {
                            // If no selected location, use the search field value as name
                            // and try to get coordinates by doing a UI script
                            
                            // Use the user entered search term for the result
                            const location: MapLocation = {
                                id: `loc-${Date.now()}-${Math.random()}`,
                                name: args.query,
                                address: "Search results - address details not available",
                                latitude: null,
                                longitude: null,
                                category: null,
                                isFavorite: false
                            };
                            locations.push(location);
                        }
                    } catch (e) {
                        // If the above didn't work, at least return something based on the query
                        const location: MapLocation = {
                            id: `loc-${Date.now()}-${Math.random()}`,
                            name: args.query,
                            address: "Search result - address details not available",
                            latitude: null,
                            longitude: null,
                            category: null,
                            isFavorite: false
                        };
                        locations.push(location);
                    }
                    
                    return locations.slice(0, args.limit);
                } catch (e) {
                    return []; // Return empty array on any error
                }
            }, { query, limit }) as MapLocation[];
            
            return {
                success: true,
                locations,
                message: locations.length > 0 ? 
                    `Found ${locations.length} location(s) for "${query}"` : 
                    `No locations found for "${query}"`
            };
        } catch (error) {
            return {
                success: false,
                locations: [],
                message: `Error searching locations: ${error instanceof Error ? error.message : String(error)}`
            };
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions operations like 'save favorites' and 'get directions,' it fails to describe authentication requirements, rate limits, data persistence, error conditions, or what the tool returns. For a multi-operation tool with 9 parameters, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that lists key capabilities without unnecessary words. It's appropriately sized for a multi-function tool, though it could be more front-loaded with the most common use cases rather than a flat list.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 9 parameters, 7 distinct operations, no annotations, and no output schema, the description is inadequate. It doesn't explain return values, error handling, operation-specific behaviors, or how parameters interact across different operations. The description should provide more operational context given the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. The baseline of 3 is appropriate since the schema does the heavy lifting, though the description doesn't compensate with additional context about parameter interactions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs (search, manage, save, get) and resources (locations, guides, favorites, directions) using Apple Maps. It distinguishes this as a maps tool among siblings like calendar and contacts, though it doesn't explicitly differentiate from potential alternative mapping tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or when specific operations are appropriate. It lists capabilities but offers no context about prerequisites, constraints, or decision criteria for choosing between operations like search vs. directions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/supermemoryai/apple-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server