Index of every page on this site: llms.txt
All skills
genkit-ai avatar

/developing-genkit-dart

@d12c988
by Genkitgenkit-ai/skills40 stars
13
Run it yourself

Provides guidance on developing AI-powered applications using the Genkit Dart SDK. Use when the user asks to build AI agents in Dart, use Genkit flows, or integrate LLMs into Dart/Flutter applications. Don't use for Genkit in JavaScript/TypeScript, Go, or Python.

Use this Skill: https://skilld.dev/gh/genkit-ai/skills/developing-genkit-dart

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesgenkit_mcp.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Genkit MCP (genkit_mcp)

MCP (Model Context Protocol) integration for Genkit Dart, built on mcp_dart. It prefers the stateless MCP 2026-07-28 protocol and falls back to initialization-based peers automatically.

Namespaced tool names are shortened on the wire. A tool like my-server/weatherTool is presented to the model as weatherTool; the full name is preserved in metadata.originalName and tool requests still resolve correctly.


MCP Host (Recommended)

Connect to one or more MCP servers and aggregate their capabilities into the Genkit registry automatically.

import 'package:genkit/genkit.dart';
import 'package:genkit_mcp/genkit_mcp.dart';

void main() async {
  final ai = Genkit();

  final host = defineMcpHost(
    ai,
    McpHostOptionsWithCache(
      name: 'my-host',
      mcpServers: {
        'fs': McpServerConfig(
          command: 'npx',
          args: ['-y', '@modelcontextprotocol/server-filesystem', '.'],
        ),
      },
    ),
  );

  // Tools can be discovered and executed dynamically using a wildcard...
  final response = await ai.generate(
    model: googleAI.gemini('gemini-flash-latest'),
    prompt: 'Summarize the contents of README.md',
    toolNames: ['my-host:tool/fs/*'],
  );
  
  // ...or by specifying the exact tool name
  final exactResponse = await ai.generate(
    model: googleAI.gemini('gemini-flash-latest'),
    prompt: 'Read README.md',
    toolNames: ['my-host:tool/fs/read_file'],
  );
}

Connect over Streamable HTTP

Point McpServerConfig at a URL instead of a command to connect over Streamable HTTP. (There is no public StreamableHttpClientTransport to construct directly; custom client transports implement the McpClientTransport interface.)

final host = defineMcpHost(
  ai,
  McpHostOptionsWithCache(
    name: 'my-host',
    mcpServers: {
      'remote': McpServerConfig(url: Uri.parse('https://mcp.example.com/mcp')),
    },
  ),
);

MCP Client (Advanced or Single Server)

Connecting to a single MCP server with a client object is an advanced usecase for when you need manual control over the client lifecycle. Standalone clients do not automatically register tools into the registry, so they must be passed into generate or defineDynamicActionProvider manually.

import 'package:genkit/genkit.dart';
import 'package:genkit_mcp/genkit_mcp.dart';

void main() async {
  final ai = Genkit();

  final client = createMcpClient(
    McpClientOptions(
      name: 'my-client',
      mcpServer: McpServerConfig(
        command: 'npx',
        args: ['-y', '@modelcontextprotocol/server-filesystem', '.'],
      ),
    ),
  );
  
  await client.ready();

  // Retrieve the tools from the connected client
  final tools = await client.getActiveTools(ai);
  
  final response = await ai.generate(
    model: googleAI.gemini('gemini-flash-latest'),
    prompt: 'Read the contents of README.md',
    tools: tools,
  );
}

MCP Server

Expose Genkit actions (tools, prompts, resources) over MCP.

import 'package:genkit/genkit.dart';
import 'package:genkit_mcp/genkit_mcp.dart';

void main() async {
  final ai = Genkit();

  ai.defineTool(
    name: 'add',
    description: 'Add two numbers together',
    inputSchema: .map(.string(), .dynamicSchema()),
    fn: (input, _) async => .response((input['a'] + input['b']).toString()),
  );

  ai.defineResource(
    name: 'my-resource',
    uri: 'my://resource',
    fn: (_, _) async => ResourceOutput(content: [TextPart(text: 'my resource')]),
  );

  // Stdio transport by default
  final server = createMcpServer(ai, McpServerOptions(name: 'my-server'));
  await server.start();
}

Streamable HTTP Transport

import 'dart:io';

final transport = await StreamableHttpServerTransport.bind(
  address: InternetAddress.loopbackIPv4,
  port: 3000,
);
await server.start(transport);

DNS-rebinding protection and batch rejection are on by default. Loopback hosts work unconfigured, but a non-loopback deployment must set allowedHosts (and should set allowedOrigins) or requests are rejected. Legacy clients that send JSON-RPC batches can opt out with rejectBatchJsonRpcPayloads: false.

final transport = await StreamableHttpServerTransport.bind(
  address: InternetAddress.anyIPv4,
  port: 3000,
  allowedHosts: ['mcp.example.com'],
  allowedOrigins: ['https://app.example.com'],
);

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 alert2d4 checks · Risk SAFE
  • Gen Agent Trust Hub3d

    The Genkit Dart skill provides comprehensive documentation and examples for building AI agents and flows using the Genkit framework. It includes guidance on using A2UI for interactive interfaces, managing agent sessions, and implementing middleware for filesystem access and multi-agent orchestration. While the skill includes instructions for installing the Genkit CLI from a vendor-controlled domain, its primary security considerations involve the attack surface for indirect prompt injection created by agents that ingest external data while possessing capabilities such as file modification and command execution.

  • Socket2d

    No alerts

  • Snyk3d

    Risk: CRITICAL · 2 issues

  • Runlayer8mo

    2/11 files flagged

Signed by skilld at d12c988. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 5 days ago
metadata
{
  "version": "1.0.0",
  "category": "AiAndMachineLearning"
}

README badge

README badge for genkit-ai/skills/developing-genkit-dart