mcpField
F
flutter-mcp-toolkit-intentcall-migration

flutter-mcp-toolkit-intentcall-migration

github.com/arenukvern开发39448 次安装2 周前更新
代码仓库

关于 flutter-mcp-toolkit-intentcall-migration

帮助 Flutter MCP Toolkit 使用者将已移除的 MCPCallEntry 迁移到 AgentCallEntry 的技能,面向升级 mcp_toolkit 的应用开发者。它提供 CLI 预览与改写步骤,并说明迁移后的注册和处理器约定。

主要功能

  1. 01检查待迁移代码
  2. 02自动改写条目用法
  3. 03迁移后注册工具条目
  4. 04使用 AgentResult 返回结果
  5. 05同步平台代码生成

适用场景

  1. 01升级后修复 MCPCallEntry 未定义错误
  2. 02将自定义工具迁移到新 API
  3. 03发布 mcp_toolkit 大版本前检查应用

MCP 相关

该技能介绍已发布的 MCP 工具 fmt_migrate_agent_entries,可默认生成迁移报告,并通过 apply: true 重写代码;也提供等效 CLI 命令。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/arenukvern/mcp_flutter --skill flutter-mcp-toolkit-intentcall-migration

安装后在 Claude Code 中输入/flutter-mcp-toolkit-intentcall-migration确认已加载。

详细介绍

IntentCall 迁移 — MCPCallEntry → AgentCallEntry

MCPCallEntry 已从 mcp_toolkit 中移除。应用代码必须使用 AgentCallEntry(来自 intentcall_core,由 mcp_toolkit 重新导出)。

规范迁移文档:migration_mcp_call_entry_to_agent_call_entry.md

何时使用此技能

  • 升级 mcp_toolkit 后,dart analyze 报告 MCPCallEntry 未定义
  • 用户要求将自定义工具/资源迁移到新 API
  • 向使用者发布 mcp_toolkit 重大版本升级前

CLI(首选)

# Preview (exit 1 if changes pending)
flutter-mcp-toolkit migrate agent-entries --check lib/

# Apply
flutter-mcp-toolkit migrate agent-entries --write lib/
flutter-mcp-toolkit migrate agent-entries --write --namespace my_app lib/main.dart

别名:migrate mcp-call-entry(行为相同)。

迁移后 — 注册

  • MCPToolkitBinding.addEntries(entries: Set<AgentCallEntry>)
  • 在 bootstrapFlutter(runApp: ...) 之前调用 addEntries(entries: { ... })
  • addMcpTool(AgentCallEntry) — 仍可作为单个条目的快捷方式

处理程序应返回 AgentResult(AgentResult.success / AgentResult.failure)。 对于使用 MCPCallResult + MCPToolDefinition 的旧版处理程序,请使用 mcpToolkitTool / mcpToolkitResource(参见 flutter-mcp-toolkit-custom-tools)。

旧版模式(之前 — 不要用于新代码)

// BEFORE (removed in Phase 6b)
final tool = MCPCallEntry.tool(
  handler: (request) async => MCPCallResult(
    message: 'ok',
    parameters: {'n': request['n']},
  ),
  definition: MCPToolDefinition(
    name: 'my_tool',
    description: 'Example',
    inputSchema: {'type': 'object', 'properties': {}},
  ),
);

目标模式(之后)

import 'package:mcp_toolkit/mcp_toolkit.dart';

final tool = AgentCallEntry.tool(
  namespace: 'app',
  name: 'my_tool',
  description: 'Example',
  inputSchema: const {
    'type': 'object',
    'additionalProperties': false,
    'properties': {'n': {'type': 'string'}},
    'required': ['n'],
  },
  handler: (final args) async {
    final n = args['n']?.toString() ?? '';
    return AgentResult.success(
      message: 'ok',
      data: {'n': n},
    );
  },
);

await MCPToolkitBinding.instance.addEntries(entries: {tool});

平台同步(可选)

工具表面编译通过后:

flutter-mcp-toolkit codegen sync --platform web
flutter-mcp-toolkit codegen sync --platform android,ios,macos --check

小米/华为平台说明见 docs/platform-notes/android-oem.md(使用与 AOSP 相同的快捷方式 XML)。

MCP migrate 工具

fmt_migrate_agent_entries 已发布(默认仅生成报告;使用 apply: true 进行重写)。CLI 等效命令:flutter-mcp-toolkit migrate agent-entries。

维护者检查清单(仓库内发布门槛)

  1. 对 showcase/flutter_test_app/lib 运行 flutter-mcp-toolkit migrate agent-entries --check
  2. 编辑任何 plugin/skills/ 内容后运行 make sync-skills
  3. cd mcp_server_dart && dart test test/contract/
  4. 搜索确认:除本文件的 BEFORE 示例外,技能中没有 MCPCallEntry

Hosted IntentCall 包

IntentCall 现已迁至此仓库之外。普通使用者状态使用 hosted intentcall_* 包。

  1. 已提交的使用者状态应使用 hosted intentcall_*: ^0.6.0 依赖。
  2. 仅在有意针对本地 IntentCall 检出版本进行跨仓库开发时,才使用本地路径覆盖。
  3. 更改依赖后,再次运行 flutter pub get 和 migrate agent-entries --check。
  4. CI:对于 hosted mcp_flutter 验证,使用 make check-intentcall-hosted-consumer;仅在有意针对本地 IntentCall 检出版本进行矩阵验证时,使用 make check-intentcall-sibling-matrix。历史目标 make check-intentcall-integration 是 sibling-matrix 流程的兼容别名,并非面向新采用者的 hosted 门槛。

相关技能

  • flutter-mcp-toolkit-custom-tools — 编写 AgentCallEntry 表面
  • flutter-mcp-toolkit-repo-maintainer — CHANGELOG、版本固定、sync-skills

评论

支持 Markdown