Skip to main content

LLM infrastructure

Function calling for an LLM that doesn't natively support it.

A prompt layer that teaches Fanar, an LLM without function calling, to speak the Model Context Protocol.

By Daniel Jeun


Most modern LLMs ship with native function calling. Fanar, the Arabic centric Islamic AI assistant, does not. That makes it a poor fit for the Model Context Protocol out of the box, since MCP assumes the model can produce a structured tool call on demand.

The usual fix is to fine tune. The fine tune is expensive and irreversible, which is the wrong tradeoff for a research demo.

The trick

Use prompts. The web app wraps the Fanar chat with a system prompt that teaches the model to emit a tool call as a fenced JSON block when it needs one. The MCP layer parses the block, runs the tool, and pushes the result back as plain text in the next turn. Fanar never has to know it lives inside an MCP system. The MCP system never has to know its model is unusual.

The result is a working MCP client paired with an LLM that was never built for it.

The server

The companion repo is an MCP server published as an npm package, @danijeun/fanar-mcp-server. It exposes three tools to any MCP client: Islamic RAG over a curated corpus, image generation, and translation. You can run it as a CLI or wire it into Claude Desktop or any other MCP host.

That part is less interesting on paper. It is the part that proves the architecture works in both directions.

TypeScript JavaScript MCP Fanar API npm

← Back to all projects