Examples

Examples

Framework integration examples for connecting to HERE Location Reasoning. Each example demonstrates a different approach — from raw protocol access to full agentic tool-calling loops with LLMs.

Before running these examples, complete the authentication setup in the Connection & Authentication Guide.

Python

MCP SDK (Direct)

File: examples/python/mcp-sdk.py

Direct tool and resource discovery and invocation using the MCP SDK — no LLM involved. Use this when you want programmatic access to location tools without an agent framework, or to explore what tools and resources are available.

cd examples/python
uv sync
uv run mcp-sdk.py

What it does: Lists available tools, calls geocode for "Alexanderplatz, Berlin", lists MCP resources, and reads the guardrails resource.

LangChain

File: examples/python/langchain-example.py

Full agent with MCP tools, resources, and prompts via AWS Bedrock. Use this when you're building with LangChain and want to add location capabilities to your existing agent.

cd examples/python
uv sync
uv run langchain-example.py

What it does: The agent receives "Can you show me a route from Paris to Berlin?", autonomously calls geocode for each city and then calculate-route, and returns a natural-language response describing the route.

Strands Agents

File: examples/python/strands-example.py

AWS-native agent with MCP tools via Bedrock. Use this when building AWS-native applications with the Strands agent framework.

cd examples/python
uv sync
uv run strands-example.py

What it does: Same routing scenario as LangChain — the agent determines which tools to call, executes them via MCP, and synthesizes a response.

PydanticAI

File: examples/python/pydantic_ai-example.py

Lightweight typed agent with MCP tools via Bedrock. Use this for type-safe agent interactions with minimal boilerplate.

cd examples/python
uv sync
uv run pydantic_ai-example.py

What it does: Same routing scenario — demonstrates PydanticAI's typed approach to tool calling with MCP.

TypeScript

MCP SDK (Direct)

File: examples/ts/mcp-sdk.ts

Direct tool and resource discovery and invocation using the MCP SDK for TypeScript — no LLM involved. Use this for programmatic access from Node.js applications.

cd examples/ts
npm install
npm run mcp-sdk

What it does: Lists available tools, calls geocode for "Alexanderplatz, Berlin", and prints the structured result.

Strands Agents

File: examples/ts/strands.ts

AWS-native agent with MCP tools via Bedrock in TypeScript. Use this for TypeScript/Node.js applications on AWS.

cd examples/ts
npm install
npm run strands

What it does: The agent receives "Can you show me a route from Paris to Berlin?" and autonomously executes the appropriate location tools to produce a route description.

Environment Variables

Set the following environment variables:

VariableRequiredDescription
HLR_SERVER_URLYeshttps://hlr.ai.here.com/mcp
AWS_ACCESS_KEY_IDYes (agent examples)AWS credentials for Bedrock LLM access
AWS_SECRET_ACCESS_KEYYes (agent examples)AWS credentials for Bedrock LLM access
AWS_DEFAULT_REGIONYes (agent examples)AWS region, e.g. us-east-1
BEDROCK_MODEL_IDYes (agent examples)Bedrock model ID

Note: Authentication requires a HERE Bearer token. See the Connection Guide for how to generate one.

Note: These examples use AWS Bedrock as the LLM provider, but MCP is model-agnostic — any LLM provider that supports tool calling works with HERE Location Reasoning.

Agent Behavior

All agent examples (LangChain, Strands, PydanticAI) load the server's usage policy (an MCP resource) and its application instructions (an MCP prompt), composing both into the system prompt. This demonstrates how to consume server-provided guardrails beyond just tools.

What's Next

  • Tools Reference — Complete list of available location tools with descriptions.