3
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?

OutSystems のサービスを MCP を使って AI から利用できるようにしてみる

Last updated at Posted at 2025-08-27

なぜやろうと思ったか

OutSystems(O11)周りでもなにか生成 AI まわりで活用できる方法ないかな、で思いついたのが REST API を介しての MCP サーバーの構築でした。
が、何となくイメージしていたものを、既に記事 ↓ としてあげている方がいらっしゃいましたので、
今回はそちらの記事も参考にさせていただきました。
記事の紹介も兼ねつつ、自身で実施してみた内容を共有します。

How to make your Outsystems services available to AI with MCP
※なお、内容の一部変更も含めた記事の掲載についてはご本人に許可をいただいております。

個人的な学習・技術向上の一環として取り組んだ内容です。

本記事のゴール

Outsystems の REST API アプリを MCP 対応にして、Claude Desktop などの AI ツールから自然言語でサービスを呼び出せるようにします。

手順

手順 1:Outsystems の Web サービスを構築する

  1. OutSystems で「Task」テーブルと構造体を作成します。
    Pasted image 20250810233303.png
    Pasted image 20250810233319.png

  2. 新しい Task を作成する REST API を構築します。
    Pasted image 20250810233548.png
    Pasted image 20250810233646.png

手順 2:MCP サーバーの作成(Node.js/TypeScript)

※なお、参照記事では Python でしたが、ここでは TypeScript で書いています。

環境を設定する

基本は公式サイトをもとに作成します。

# プロジェクト作成
md mcp-task-server
cd mcp-task-server
npm init -y

# 必要なパッケージのインストール
npm install @modelcontextprotocol/sdk zod axios
npm install -D @types/node typescript

# ファイルを作成する
md src
New-item src\index.ts

package.json を更新して、type: “module”とビルド スクリプトを追加します。
※Windows なので、公式にあるchmod部分は不要です。

{
  "type": "module",
  "bin": {
    "task-server": "./build/index.js"
  },
  "scripts": {
    "build": "tsc"
  },
  "files": ["build"]
}

tsconfig.json を作成します。

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "Node16",
    "moduleResolution": "Node16",
    "outDir": "./build",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

サーバーを構築する

src/index.tsに以下を追加します。

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
import { config } from "dotenv";

// Load environment variables from .env file
config();

const TASK_API_BASE =
  process.env.TASK_API_BASE ||
  "https://xxx.outsystemscloud.com/Mcp/rest/TaskApi";

// Create server instance
const server = new McpServer({
  name: "task-server",
  version: "1.0.0",
  capabilities: {
    resources: {},
    tools: {},
  },
});

// Helper function for creating tasks via TaskAPI
async function createTask(taskData: TaskStructure): Promise<string | null> {
  const url = `${TASK_API_BASE}/CreateTask`;

  try {
    const response = await fetch(url, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify(taskData),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    return await response.text();
  } catch (error) {
    console.error("Error creating task:", error);
    return null;
  }
}

// Task structure interface based on swagger definition
interface TaskStructure {
  Title: string;
  Description: string;
  Priority: number;
  DueDate: string; // format: date (YYYY-MM-DD)
  Status: number;
}

// Register task tools
server.tool(
  "create_task",
  "Create a new task using TaskAPI",
  {
    title: z.string().describe("Title of the task"),
    description: z.string().describe("Description of the task"),
    priority: z
      .number()
      .int()
      .min(0)
      .describe("Priority of the task (integer, 0 or higher)"),
    dueDate: z
      .string()
      .regex(/^\d{4}-\d{2}-\d{2}$/)
      .describe("Due date in YYYY-MM-DD format"),
    status: z
      .number()
      .int()
      .min(0)
      .describe("Status of the task (integer, 0 or higher)"),
  },
  async ({ title, description, priority, dueDate, status }) => {
    const taskData: TaskStructure = {
      Title: title,
      Description: description,
      Priority: priority,
      DueDate: dueDate,
      Status: status,
    };

    const result = await createTask(taskData);

    if (result === null) {
      return {
        content: [
          {
            type: "text",
            text: "Failed to create task. Please check the API connection and parameters.",
          },
        ],
      };
    }

    return {
      content: [
        {
          type: "text",
          text: `Task created successfully. Response: ${result}`,
        },
      ],
    };
  }
);

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error("Task MCP Server running on stdio");
}

main().catch((error) => {
  console.error("Fatal error in main():", error);
  process.exit(1);
});

1 ファイルで色々無理感がつよいですが、テスト用のためご容赦ください。
ざっくり内容としてはconst server = new McpServer()で、MCP Server を定義して、server.tool() で MCP Server の tools(create_task) を登録しています。
また、tools の createTask() 内では、OutSystems の CreateTask API にリクエストを行っています。

手順 3:ビルドと Claude Desktop へのインストール

ビルド

js ファイルをビルドしておきます。
./build/index.jsが作成されます。)

npm run build

Claude Desktop 設定ファイルの編集

%APPDATA%\Claude\claude_desktop_config.jsonに以下を追加します。

{
  "mcpServers": {
    "task-server": {
      "command": "node",
      "args": ["C:\\PATH\\TO\\PARENT\\FOLDER\\mcp-task-server\\build\\index.js"]
    }
  }
}

※PATH の部分は適宜環境に応じて変更してください。
※Claude Desktop を起動している場合は一度再起動します。

その後、Claude Desktop で公開したツールを認識していることを確認します。
「Search and tools」アイコンから確認できます。
Pasted image 20250810232708.png


image.png

OK そうです。
※MCP Server の読み込みに失敗する場合は Settings の Developer タブから log の確認ができますので、エラー内容を確認してみてください。
自分はclaude_desktop_config.jsonの path が違って一度エラーになりました。

手順 4:Claude Desktop からタスクを作成する

これで、OutSystems に触れることなく、自然言語を使用して Claude Desktop からタスクを作成できるようになりました。
実際にやってみます。

こんな感じで指示をだしてみます。

image.png
(「タスク」といえば該当の MCPTools を参照してくれるかなとおもい、雑に依頼してみてます。)

Claude にツールの実行を許可する必要があります。
今回は「Allow once」を選択します。
Pasted image 20250810230018.png

結果がこちらです。うまくいきました。
Pasted image 20250810230050.png

実際に OutSystems 側の Database にもデータが追加されています 🎉
Pasted image 20250810230131.png

まとめ・感想

ローカルで動かすだけではありますが、
1 時間ほどでさくっとできて興味深かったです。

今回の内容はあくまで外から API リクエストしているだけですし、おためし感が強いので、
今後活用方法が広がっていくと面白そうではあります。
(参照記事の方も「My article was only a starting point(私の記事は単なる出発点に過ぎません)」とおっしゃっていました。)

※なお REST API で公開する際に、OutSystems の System テーブルを書き換えすることのないよう、ご注意ください。

現状 OutSystems の ODC では一定の生成 AI 関連機能が組み込まれていますが、
O11 ではまだ活用できるタイミングは少ないと感じています。
O11 のサポートが継続することでこのあたりの動きが OutSystems 内外で活発化すると良いな思います。

最後に、快く掲載許可をいただき、またとても丁寧にご対応いただきました参照記事の Nelson André 様に深く深く感謝いたします。
ありがとうございました。

3
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
3
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?