needle_haystack_generate
Generate a "needle in a haystack" test: embeds a target fact into a large block of filler text at a specified position. Use this to test LLM context window retrieval accuracy. Returns the full haystack, the question to ask, and metadata. No API key needed.
Example tool call
This call uses example arguments supplied in the tool’s input schema.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"needle": "The code is 4242.",
"tokens": 2000,
"position": "middle",
"question": "What is the code?"
},
"name": "needle_haystack_generate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| needle | Yes | The fact to hide (e.g. "The secret code is ALPHA-42") | |
| tokens | No | Target haystack size in tokens (default: 5000, max: 100000) | |
| position | No | Where to insert the needle: "start", "middle", "end", "random" (default: "middle") | middle |
| question | Yes | The question to ask the LLM (e.g. "What is the secret code?") |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| needle | No | ||
| haystack | No | ||
| position | No | ||
| question | No | ||
| insert_block | No | ||
| total_blocks | No | ||
| estimated_tokens | No |