Skip to main content
Glama

jina_grounding_enhance

Enhance content accuracy by verifying statements in real-time against web knowledge, reducing errors and improving integrity with automated fact-checking.

Instructions

Real-time fact verification against web knowledge. Reduces hallucinations and improves content integrity through statement verification.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent to enhance

Implementation Reference

  • Core handler function that executes the Jina grounding enhancement: calls Jina API for fact-checking, processes response, and formats the enhanced content with factuality score, verdict, reasoning, and references.
    async enhance_content(content: string): Promise<EnhancementResult> { const api_key = validate_api_key( config.enhancement.jina_grounding.api_key, this.name, ); const ground_request = async () => { try { const data = await http_json<JinaGroundingResponse>( this.name, 'https://g.jina.ai', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${api_key}`, }, body: JSON.stringify({ statement: content }), signal: AbortSignal.timeout( config.enhancement.jina_grounding.timeout, ), }, ); if (!data?.data) { throw new ProviderError( ErrorType.API_ERROR, 'Unexpected response: missing data from Jina Grounding', this.name, ); } // Format references into a readable string const references_text = data.data.references .map( (ref) => `${ref.is_supportive ? '✓' : '✗'} ${ref.key_quote} (${ ref.url })`, ) .join('\n\n'); return { original_content: content, enhanced_content: `Factuality Score: ${ data.data.factuality }\nVerdict: ${ data.data.result ? 'True' : 'False' }\n\nReasoning: ${ data.data.reason }\n\nReferences:\n${references_text}`, enhancements: [ { type: 'fact_verification', description: 'Verified factual accuracy against real-time web knowledge', }, ], sources: data.data.references.map((ref) => ({ title: ref.key_quote, url: ref.url, })), source_provider: this.name, meta: { factuality: data.data.factuality, result: data.data.result, token_usage: data.data.usage.tokens, }, }; } catch (error) { handle_provider_error(error, this.name, 'ground content'); } }; return retry_with_backoff(ground_request); }
  • Conditionally registers the JinaGroundingProvider instance if the API key is valid, making it available for tool registration as 'jina_grounding_enhance'.
    if ( is_api_key_valid( config.enhancement.jina_grounding.api_key, 'jina_grounding', ) ) { register_enhancement_provider(new JinaGroundingProvider()); }
  • Dynamically registers the 'jina_grounding_enhance' tool (via provider.name + '_enhance'), defines input schema requiring 'content' string, and provides a wrapper handler that calls the provider's enhance_content method.
    this.enhancement_providers.forEach((provider) => { server.tool( { name: `${provider.name}_enhance`, description: provider.description, schema: v.object({ content: v.pipe(v.string(), v.description('Content')), }), }, async ({ content }) => { try { const result = await provider.enhance_content(content); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const error_response = create_error_response( error as Error, ); return { content: [ { type: 'text' as const, text: error_response.error, }, ], isError: true, }; } }, ); });
  • Input schema for the enhancement tools, including jina_grounding_enhance: requires a 'content' string parameter.
    schema: v.object({ content: v.pipe(v.string(), v.description('Content')), }),
  • Defines the provider class with name 'jina_grounding' (used to derive tool name 'jina_grounding_enhance') and description.
    export class JinaGroundingProvider implements EnhancementProvider { name = 'jina_grounding'; description = 'Real-time fact verification against web knowledge. Reduces hallucinations and improves content integrity through statement verification.';

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-omnisearch'

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