Skip to main content
Glama
JunWoo0406

TypeScript MCP Server Boilerplate

by JunWoo0406

geocode

Convert city names or addresses into latitude and longitude coordinates using the Nominatim OpenStreetMap API for location-based applications.

Instructions

도시 이름이나 주소를 입력하면 위도(lat)와 경도(lon) 좌표를 반환합니다. Nominatim OpenStreetMap API를 사용합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes검색할 도시 이름 또는 주소 (예: 서울, Tokyo, Paris)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes

Implementation Reference

  • The 'geocode' tool is registered using `server.registerTool` in `src/index.ts`. It takes a `query` string and uses the Nominatim OpenStreetMap API to retrieve the geographical coordinates (latitude and longitude) for the given location.
    server.registerTool(
        'geocode',
        {
            description: '도시 이름이나 주소를 입력하면 위도(lat)와 경도(lon) 좌표를 반환합니다. Nominatim OpenStreetMap API를 사용합니다.',
            inputSchema: z.object({
                query: z.string().describe('검색할 도시 이름 또는 주소 (예: 서울, Tokyo, Paris)')
            }),
            outputSchema: z.object({
                content: z.array(
                    z.object({
                        type: z.literal('text'),
                        text: z.string().describe('위도/경도 좌표 결과')
                    })
                )
            })
        },
        async ({ query }) => {
            const url = `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(query)}&format=json&limit=1`
    
            const response = await fetch(url, {
                headers: {
                    'User-Agent': 'MCP-Geocode-Tool/1.0'
                }
            })
    
            if (!response.ok) {
                const errorText = `오류: API 요청 실패 (상태 코드: ${response.status})`
                return {
                    content: [{ type: 'text' as const, text: errorText }],
                    structuredContent: { content: [{ type: 'text' as const, text: errorText }] }
                }
            }
    
            const results = (await response.json()) as Array<{
                lat: string
                lon: string
                display_name: string
            }>
    
            if (results.length === 0) {
                const errorText = `"${query}"에 대한 검색 결과가 없습니다.`
                return {
                    content: [{ type: 'text' as const, text: errorText }],
                    structuredContent: { content: [{ type: 'text' as const, text: errorText }] }
                }
            }
    
            const { lat, lon, display_name } = results[0]
            const text = `📍 ${display_name}\n위도(lat): ${lat}\n경도(lon): ${lon}`
    
            return {
                content: [{ type: 'text' as const, text }],
                structuredContent: { content: [{ type: 'text' as const, text }] }
            }
        }
    )
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the external dependency ('Nominatim OpenStreetMap API'), informing the agent about the data source. However, it lacks details on error behavior (e.g., ambiguous queries, not-found locations), rate limits, or whether the operation is idempotent.

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

Conciseness5/5

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

Two efficient sentences with zero waste. The first front-loads the core action (input→output transformation), while the second adds valuable implementation context (external API dependency). Every sentence earns its place.

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

Completeness4/5

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

Given the tool's simple single-parameter nature, 100% schema coverage, and existence of an output schema, the description is appropriately complete. It identifies the return values (lat/lon) without needing to detail the full output structure. Minor gap: no mention of error cases or ambiguous results.

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 baseline is 3. The description reinforces the parameter's purpose ('도시 이름이나 주소' / city name or address) but does not add semantic constraints or format guidance beyond what the schema already provides (e.g., no guidance on preferred address formats or disambiguation hints).

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

Purpose5/5

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

The description clearly states the transformation function (input city name/address → output lat/lon coordinates) using specific verbs and resources. It clearly distinguishes from siblings (calc, generate-image, get-weather, etc.) by specifying geocoding functionality that none of the others provide.

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, particularly sibling 'get-weather' which may also accept location inputs. It does not clarify whether locations should be geocoded first before passing to other tools or if those tools accept raw city names.

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

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/JunWoo0406/my-mcp-server'

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