Skip to main content
Glama
jicoing

MCP Image Metadata Server

by jicoing

detect_image_manipulation

Analyze images for signs of manipulation with basic, standard, or forensic analysis levels. Supports x402 payment for access.

Instructions

Analyze image for manipulation signs. Price: $0.002-0.015 USDC via x402

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageUrlYes
analysisLevelNostandard
paymentHeaderNox402 payment header (if paying for access)
payerNoCaller wallet address (for freemium tracking)

Implementation Reference

  • src/index.ts:96-119 (registration)
    Registration of the 'detect_image_manipulation' tool in the tool list (stdio server)
    {
      name: 'detect_image_manipulation',
      description: `Analyze image for manipulation signs. Price: $${PRICING.standard.price}-${PRICING.forensic.price} USDC via x402`,
      inputSchema: {
        type: 'object',
        properties: {
          imageUrl: { type: 'string' },
          analysisLevel: {
            type: 'string',
            enum: ['basic', 'standard', 'forensic'],
            default: 'standard',
          },
          paymentHeader: {
            type: 'string',
            description: 'x402 payment header (if paying for access)',
          },
          payer: {
            type: 'string',
            description: 'Caller wallet address (for freemium tracking)',
          },
        },
        required: ['imageUrl'],
      },
    },
  • Registration of the 'detect_image_manipulation' tool in the tool list (HTTP server)
    {
      name: 'detect_image_manipulation',
      description: `Analyze image for manipulation. Price: $${PRICING.standard.price}-${PRICING.forensic.price} USDC via x402`,
      inputSchema: {
        type: 'object',
        properties: {
          imageUrl: { type: 'string' },
          analysisLevel: { type: 'string', enum: ['basic', 'standard', 'forensic'] },
          paymentHeader: { type: 'string' },
          payer: { type: 'string' },
        },
        required: ['imageUrl'],
      },
    },
  • Zod schema for the tool's input validation (AnalyzeInputSchema) and type definition
    export const AnalyzeInputSchema = z.object({
      imageUrl: z.string(),
      analysisLevel: z.enum(['basic', 'standard', 'forensic']).default('standard'),
    });
    
    export type AnalyzeInput = z.infer<typeof AnalyzeInputSchema>;
  • Main handler function 'handleAnalyze' that orchestrates payment verification and calls detectManipulation
    export async function handleAnalyze(
      input: AnalyzeInput,
      paymentHeader?: string,
      payer?: string
    ): Promise<{
      success: boolean;
      data?: {
        isManipulated: boolean;
        confidence: number;
        details: string[];
      };
      price?: number;
      paymentStatus?: string;
      freemiumRemaining?: number;
      error?: string;
    }> {
      try {
        const { imageUrl, analysisLevel } = input;
        const tier = analysisLevel as 'basic' | 'standard' | 'forensic';
        const price = calculatePrice(tier);
    
        if (paymentHeader || !checkFreemium(payer).allowed) {
          const payment = await verifyPayment(paymentHeader, tier, payer);
          if (!payment.valid) {
            return {
              success: false,
              price,
              paymentStatus: 'failed',
              freemiumRemaining: 0,
              error: payment.error || 'Payment verification failed',
            };
          }
        }
    
        const freemium = checkFreemium(payer);
        const result = await detectManipulation(imageUrl, analysisLevel);
    
        return {
          success: true,
          data: result,
          price,
          paymentStatus: freemium.allowed ? 'free' : 'paid',
          freemiumRemaining: freemium.allowed ? freemium.remaining : 0,
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Core manipulation detection logic - checks EXIF software tags, date mismatches, and channel variance (forensic)
    export async function detectManipulation(
      imagePath: string,
      analysisLevel: 'basic' | 'standard' | 'forensic' = 'standard'
    ): Promise<{ isManipulated: boolean; confidence: number; details: string[] }> {
      const details: string[] = [];
      let manipulationScore = 0;
    
      const buffer = await sharp(imagePath).toBuffer();
      const tags = ExifReader.load(buffer);
    
      if (tags.exif) {
        const exif = tags.exif as unknown as Record<string, unknown>;
        
        if (exif.Software && analysisLevel !== 'basic') {
          details.push(`Software: ${String(exif.Software)}`);
          manipulationScore += 10;
        }
    
        if (exif.ModifyDate && exif.DateTimeOriginal) {
          const modifyDate = getStringFromTag(exif.ModifyDate);
          const origDate = getStringFromTag(exif.DateTimeOriginal);
          if (modifyDate && origDate && modifyDate !== origDate) {
            details.push('EXIF modification date differs from original');
            manipulationScore += 30;
          }
        }
      }
    
      const stats = await sharp(imagePath).stats();
      if (stats.channels) {
        const channelVariances = stats.channels.map(ch => {
          const mean = ch.mean || 0;
          const std = (ch as { stdev?: number }).stdev || 0;
          return std / (mean || 1);
        });
    
        const variance = channelVariances.reduce((a, b) => a + b, 0) / channelVariances.length;
        if (variance > 10 && analysisLevel === 'forensic') {
          details.push('Unusual channel variance detected');
          manipulationScore += 20;
        }
      }
    
      const confidence = Math.min(manipulationScore, 100);
      return {
        isManipulated: manipulationScore > 50,
        confidence,
        details,
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description should fully disclose behavior. Only mentions pricing ($0.002-0.015 USDC) but not what the analysis entails, side effects, or limitations.

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

Conciseness3/5

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

Extremely brief (single sentence) but lacks essential details. Adequate conciseness but under-specified.

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

Completeness2/5

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

No output schema, 4 parameters including payment and freemium fields. Description does not explain return values, error handling, or behavior changes with different analysis levels.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 50%, but description adds no parameter-specific meaning. Parameters like 'analysisLevel' (with enum) are not elaborated beyond schema.

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?

Description clearly states verb 'Analyze' and resource 'image' with specific purpose 'for manipulation signs'. Distinct from siblings (extract_batch_metadata, extract_image_metadata, get_pricing) which focus on metadata or pricing.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. Mentions pricing and payment parameters but does not specify context or exclude cases.

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/jicoing/mcp-image-metadata'

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