0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

note下書きMCPでアカウント混同を防ぐ:route_id・account・secret名を公開前に固定する

0
Posted at

note下書きMCPのアカウント混同防止 - route_id、account、secretを固定する

note下書き前のルーティング確認 - route table、frontmatter、secret name、draft action

はじめに

noteの自動投稿で怖いのは、APIやブラウザ操作が失敗することだけではありません。もっと怖いのは、正しい本文を間違ったアカウントへ下書き・公開してしまうことです。

Agent Memoriesでは、公式note、個人note、別ブランドのnoteを分けて扱います。そのため、新しい下書きや投稿を作る前に、必ず route_id、媒体、対象アカウント、使用secret名、操作種別を固定します。

この記事では、note下書きMCPでアカウント混同を防ぐための最小設計をまとめます。

route tableを正本にする

投稿先はプロンプト内の文章ではなく、設定ファイルを正本にします。

{
  "routes": {
    "agent_memories_official": {
      "platforms": {
        "note": {
          "account": "agent_memories",
          "secret": "note-proxy-profile:agent_memories"
        }
      }
    }
  }
}

MCPはこの台帳を読み、入力された route_idplatform から対象アカウントを決めます。本文側で account: "別アカウント" と書かれていた場合は、台帳と一致しないため停止します。

下書き入力にroute_idを必須にする

note下書きMCPの入力では、route_idを必須にします。

type NoteDraftInput = {
  route_id: "agent_memories_official";
  platform: "note";
  slug: string;
  title: string;
  bodyMarkdown: string;
  operation: "create_draft";
};

route_id を省略できる設計にすると、実行時の環境変数や既定値に引っ張られます。自動化では、その「なんとなくの既定」が事故になります。

secret名はログに残すが値は出さない

確認に必要なのは、どのsecretを使う予定かです。secretの値ではありません。

type RouteResolution = {
  route_id: string;
  platform: "note";
  account: string;
  secret_name: string;
};

ログには secret_name だけを残します。Cookie、token、Auth header、セッション内容は出しません。デバッグ時も、secret値を表示しない関数だけを使います。

frontmatterと台帳を照合する

下書き原稿側にも、投稿先を明記します。

---
route_id: "agent_memories_official"
platform: "note"
account: "agent_memories"
operation: "create_draft"
---

実行前に、frontmatterとroute tableを照合します。

function assertRouteMatches(input: NoteDraftInput, resolved: RouteResolution) {
  if (input.route_id !== resolved.route_id) throw new Error("route_id mismatch");
  if (input.platform !== resolved.platform) throw new Error("platform mismatch");
}

ここでは「違っていたら直して続行」ではなく、停止します。アカウント混同は自動補正してはいけない種類の事故です。

公開と下書きを分ける

下書き作成と公開は、別の操作にします。

type NoteOperation = "create_draft" | "update_draft" | "publish";

create_draft は本文を置くだけです。publish は、アカウント、タイトル、本文、アイキャッチ、タグ、公開状態を再確認した後にだけ実行します。

この分離があると、下書き段階でレビューを挟めます。特に法人用・公式用アカウントでは、公開操作だけを強い権限の担当者に限定できます。

まとめ

note下書きMCPで守るべきことは、本文生成の品質だけではありません。投稿先アカウントの混同を防ぐことが最優先です。

最小構成は次の4つです。

  1. route tableを正本にする
  2. route_idを入力とfrontmatterで必須にする
  3. secret名だけをログに残し、secret値は出さない
  4. 下書き作成と公開を分離する

AIエージェントが記事制作を手伝うほど、出口の管理が重要になります。route_idで投稿先を固定しておくと、便利さを増やしながら事故の範囲を小さくできます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?