Skip to main content
Glama
spences10

Jina.ai Grounding MCP Server

ground_statement

Verify statement accuracy by grounding claims with real-time web search results to check factuality and provide evidence-based validation.

Instructions

Ground a statement using real-time web search results to check factuality. When providing URLs via the references parameter, ensure they are publicly accessible and contain relevant information about the statement. If the URLs do not contain the necessary information, try removing the URL restrictions to search the entire web.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statementYesStatement to be grounded
referencesNoOptional list of URLs to restrict search to. Only provide URLs that are publicly accessible and contain information relevant to the statement. If the URLs do not contain the necessary information, the grounding will fail. For best results, either provide URLs you are certain contain the information, or omit this parameter to search the entire web.
no_cacheNoWhether to bypass cache for fresh results

Implementation Reference

  • The main handler for executing the 'ground_statement' tool. It validates input, makes a POST request to Jina AI's grounding API with optional site restrictions and no-cache header, handles errors including specific URL validation failures, and returns the grounding response as JSON.
    this.server.setRequestHandler(
    	CallToolRequestSchema,
    	async (request) => {
    		if (request.params.name !== 'ground_statement') {
    			throw new McpError(
    				ErrorCode.MethodNotFound,
    				`Unknown tool: ${request.params.name}`,
    			);
    		}
    
    		const args = request.params.arguments;
    
    		if (!is_valid_grounding_args(args)) {
    			throw new McpError(
    				ErrorCode.InvalidParams,
    				'Invalid parameters. Required: statement (string). Optional: references (string[]), no_cache (boolean)',
    			);
    		}
    
    		try {
    			const headers: Record<string, string> = {
    				'Content-Type': 'application/json',
    				Accept: 'application/json',
    				Authorization: `Bearer ${JINAAI_API_KEY}`,
    			};
    
    			// Add optional headers
    			if (args.references?.length) {
    				headers['X-Site'] = args.references.join(',');
    			}
    			if (args.no_cache) {
    				headers['X-No-Cache'] = 'true';
    			}
    
    			const response = await fetch(this.base_url, {
    				method: 'POST',
    				headers,
    				body: JSON.stringify({
    					statement: args.statement.trim(),
    				}),
    			});
    
    			if (!response.ok) {
    				const error_text = await response.text();
    				let error_json;
    				try {
    					error_json = JSON.parse(error_text);
    				} catch {
    					throw new Error(
    						`HTTP error! status: ${response.status}, message: ${error_text}`,
    					);
    				}
    
    				// Handle specific error cases
    				if (error_json.status === 42206) {
    					throw new McpError(
    						ErrorCode.InvalidParams,
    						'The provided URLs did not contain relevant information for fact-checking. This can happen when:\n' +
    						'1. The URLs are not publicly accessible\n' +
    						'2. The URLs do not contain information about the specific statement\n' +
    						'3. The information exists but is not in an easily searchable format\n\n' +
    						'Suggestions:\n' +
    						'- Remove the URL restrictions to search the entire web\n' +
    						'- Provide different URLs that you are certain contain the information\n' +
    						'- Verify the URLs are publicly accessible and contain relevant content',
    					);
    				}
    
    				// Handle other API errors
    				throw new Error(
    					`API error! status: ${response.status}, message: ${error_json.readableMessage || error_json.message || error_text}`,
    				);
    			}
    
    			const result = (await response.json()) as {
    				code: number;
    				status: number;
    				data: GroundingResponse;
    			};
    
    			if (result.code !== 200) {
    				throw new Error(`API error! status: ${result.status}`);
    			}
    
    			return {
    				content: [
    					{
    						type: 'text',
    						text: JSON.stringify(result.data, null, 2),
    					},
    				],
    			};
    		} catch (error) {
    			const message =
    				error instanceof Error ? error.message : String(error);
    			throw new McpError(
    				ErrorCode.InternalError,
    				`Failed to ground statement: ${message}`,
    			);
    		}
    	},
    );
  • Input schema for the ground_statement tool, defining parameters: statement (required string), references (optional array of strings), no_cache (optional boolean).
    inputSchema: {
    	type: 'object',
    	properties: {
    		statement: {
    			type: 'string',
    			description: 'Statement to be grounded',
    		},
    		references: {
    			type: 'array',
    			items: {
    				type: 'string',
    			},
    			description:
    				'Optional list of URLs to restrict search to. Only provide URLs that are ' +
    				'publicly accessible and contain information relevant to the statement. ' +
    				'If the URLs do not contain the necessary information, the grounding will fail. ' +
    				'For best results, either provide URLs you are certain contain the information, ' +
    				'or omit this parameter to search the entire web.',
    		},
    		no_cache: {
    			type: 'boolean',
    			description:
    				'Whether to bypass cache for fresh results',
    			default: false,
    		},
    	},
    	required: ['statement'],
    },
  • src/index.ts:90-126 (registration)
    Registration of the ground_statement tool in the ListTools response, including name, description, and input schema reference.
    	{
    		name: 'ground_statement',
    		description:
    			'Ground a statement using real-time web search results to check factuality. ' +
    			'When providing URLs via the references parameter, ensure they are publicly accessible ' +
    			'and contain relevant information about the statement. If the URLs do not contain ' +
    			'the necessary information, try removing the URL restrictions to search the entire web.',
    		inputSchema: {
    			type: 'object',
    			properties: {
    				statement: {
    					type: 'string',
    					description: 'Statement to be grounded',
    				},
    				references: {
    					type: 'array',
    					items: {
    						type: 'string',
    					},
    					description:
    						'Optional list of URLs to restrict search to. Only provide URLs that are ' +
    						'publicly accessible and contain information relevant to the statement. ' +
    						'If the URLs do not contain the necessary information, the grounding will fail. ' +
    						'For best results, either provide URLs you are certain contain the information, ' +
    						'or omit this parameter to search the entire web.',
    				},
    				no_cache: {
    					type: 'boolean',
    					description:
    						'Whether to bypass cache for fresh results',
    					default: false,
    				},
    			},
    			required: ['statement'],
    		},
    	},
    ],
  • Helper function to validate the arguments for the ground_statement tool against GroundingOptions interface.
    const is_valid_grounding_args = (
    	args: any,
    ): args is GroundingOptions =>
    	typeof args === 'object' &&
    	args !== null &&
    	typeof args.statement === 'string' &&
    	args.statement.trim() !== '' &&
    	(args.references === undefined ||
    		(Array.isArray(args.references) &&
    			args.references.every((ref: string) => typeof ref === 'string'))) &&
    	(args.no_cache === undefined || typeof args.no_cache === 'boolean');
  • TypeScript interfaces defining the input (GroundingOptions) and output (GroundingResponse, GroundingReference) structures for the ground_statement tool.
    interface GroundingReference {
    	url: string; // Source URL
    	keyQuote: string; // Supporting quote from the source
    	isSupportive: boolean; // Whether the reference supports or contradicts the statement
    }
    
    interface GroundingResponse {
    	factuality: number; // Score between 0-1 indicating confidence
    	result: boolean; // True if statement is verified as factual
    	reason: string; // Explanation of the verification result
    	references: GroundingReference[]; // Supporting/contradicting sources (up to 30)
    	usage: {
    		tokens: number; // Number of tokens processed
    	};
    }
    
    interface GroundingOptions {
    	statement: string; // Statement to verify
    	references?: string[]; // Optional list of URLs to restrict search to
    	no_cache?: boolean; // Whether to bypass cache for fresh results
    }
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 of behavioral disclosure. It describes key traits like using real-time web search, the impact of URL restrictions (grounding may fail if URLs lack info), and the option to bypass cache. However, it omits details such as rate limits, authentication needs, or specific error handling, leaving some behavioral aspects unclear.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose. Both sentences earn their place by adding useful context about URL handling, though it could be slightly more streamlined by avoiding minor redundancy with the schema (e.g., repeating URL accessibility advice).

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

Completeness3/5

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

Given the tool's complexity (fact-checking with web search) and no annotations or output schema, the description is moderately complete. It covers the main purpose and parameter usage but lacks details on output format, error cases, or performance expectations, which are important for an agent to use it effectively without structured output guidance.

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 schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by reiterating guidance on the references parameter (e.g., ensuring URLs are accessible and relevant), but it doesn't provide additional semantic context or examples not covered in the schema, warranting a 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 tool's purpose with a specific verb ('ground') and resource ('statement'), explaining it uses real-time web search to check factuality. It distinguishes the action from generic search by specifying the grounding objective, and with no sibling tools, this level of specificity is excellent.

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

Usage Guidelines4/5

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

The description provides clear context on when to use the tool (for fact-checking statements) and includes guidance on the references parameter (e.g., ensure URLs are publicly accessible and relevant, or omit to search the entire web). However, it lacks explicit alternatives or exclusions, as there are no sibling tools, so it doesn't fully address when-not-to-use scenarios.

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/spences10/mcp-jinaai-grounding'

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