Skip to main content
Glama
bakcoder

TypeScript MCP Server Boilerplate

by bakcoder

geocode

Convert city names or addresses into latitude and longitude coordinates using the Nominatim OpenStreetMap API. Supports country filtering and result limits.

Instructions

도시 이름이나 주소를 입력받아 위도·경도 좌표를 반환합니다. (Nominatim OpenStreetMap API 사용)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes도시 이름 또는 주소
limitNo최대 결과 수 (기본값: 5, 최대: 10)
countrycodesNo국가 코드 필터 (ISO 3166-1 alpha-2, 예: "kr,us")

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
resultsYes

Implementation Reference

  • The 'geocode' tool is registered using 'server.registerTool' in src/index.ts, with its input/output schemas and execution logic (handler) directly defined within the call. The handler makes a request to the Nominatim OpenStreetMap API.
    server.registerTool(
        'geocode',
        {
            description:
                '도시 이름이나 주소를 입력받아 위도·경도 좌표를 반환합니다. (Nominatim OpenStreetMap API 사용)',
            inputSchema: z.object({
                query: z.string().describe('도시 이름 또는 주소'),
                limit: z
                    .number()
                    .int()
                    .min(1)
                    .max(10)
                    .optional()
                    .default(5)
                    .describe('최대 결과 수 (기본값: 5, 최대: 10)'),
                countrycodes: z
                    .string()
                    .optional()
                    .describe('국가 코드 필터 (ISO 3166-1 alpha-2, 예: "kr,us")')
            }),
            outputSchema: z.object({
                content: z.array(
                    z.object({
                        type: z.literal('text'),
                        text: z.string().describe('검색 결과 요약 메시지')
                    })
                ),
                results: z.array(
                    z.object({
                        displayName: z.string().describe('전체 주소 문자열'),
                        lat: z.number().describe('위도'),
                        lon: z.number().describe('경도'),
                        type: z.string().describe('장소 유형'),
                        importance: z.number().describe('관련도 점수')
                    })
                )
            })
        },
        async ({ query, limit, countrycodes }) => {
            const params = new URLSearchParams({
                q: query,
                format: 'json',
                addressdetails: '1',
                limit: String(limit)
            })
            if (countrycodes) {
                params.set('countrycodes', countrycodes)
            }
    
            const response = await fetch(
                `https://nominatim.openstreetmap.org/search?${params}`,
                {
                    headers: {
                        'User-Agent': 'typescript-mcp-server/1.0',
                        'Accept-Language': 'ko,en'
                    }
                }
            )
    
            if (!response.ok) {
                throw new Error(
                    `Nominatim API 오류: ${response.status} ${response.statusText}`
                )
            }
    
            const data = (await response.json()) as Array<{
                lat: string
                lon: string
                display_name: string
                type: string
                importance: number
            }>
    
            if (data.length === 0) {
                throw new Error(`"${query}"에 대한 검색 결과가 없습니다.`)
            }
    
            const results = data.map((item) => ({
                displayName: item.display_name,
                lat: parseFloat(item.lat),
                lon: parseFloat(item.lon),
                type: item.type,
                importance: item.importance
            }))
    
            const summary = results
                .map(
                    (r, i) =>
                        `${i + 1}. ${r.displayName}\n   위도: ${r.lat}, 경도: ${r.lon}`
                )
                .join('\n')
            const message = `"${query}" 검색 결과 ${results.length}건:\n${summary}`
    
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: message
                    }
                ],
                structuredContent: {
                    content: [
                        {
                            type: 'text' as const,
                            text: message
                        }
                    ],
                    results
                }
            }
        }
    )
Behavior4/5

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

No annotations are provided, so the description carries the full disclosure burden. It successfully identifies the external API dependency (Nominatim OpenStreetMap), signaling network usage, potential rate limits, and data source attribution requirements. However, it omits explicit mention of blocking behavior, error handling when locations are not found, or rate limit specifics.

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?

The description is a single, efficient sentence with the API attribution parenthetically appended. Every element earns its place: the input types, the output format, and the service provider. No redundancy or verbosity.

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 presence of an output schema (not shown but indicated in context signals), the description appropriately omits return value details. With 100% parameter coverage in the schema and clear API identification in the description, it is complete for the tool's complexity level, though it could briefly mention error scenarios for perfection.

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?

With 100% schema description coverage, the schema already comprehensively documents all three parameters including type constraints and examples (e.g., ISO 3166-1 alpha-2 format for countrycodes). The description mentions '도시 이름이나 주소' aligning with the query parameter but does not add semantic value beyond the schema definitions, warranting the baseline score.

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 specific action (반환합니다/returns), input types (도시 이름이나 주소/city names or addresses), and output (위도·경도 좌표/latitude-longitude coordinates). It includes the underlying API provider (Nominatim OpenStreetMap), distinguishing it from unrelated siblings like calc, generate-image, and get-weather.

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

Usage Guidelines3/5

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

The description implies usage context through input/output specification but lacks explicit guidance on when to use this tool versus alternatives, or prerequisites like network availability. Given the siblings are completely unrelated (calc, greet, time), the absence of explicit differentiation is mitigated but still present.

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

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