Mcp Serverのロゴ

Mcp Server

組織
Happy-Technologies-LLC
mcp-server

Set up ServiceNow as an MCP (Model Context Protocol) server defining tool capabilities, authentication, resource endpoints, and integration patterns for AI agents

概要

公開者Happy-Technologies-LLC
リポジトリhappy-platform-skills
スキル名mcp-server
スター
41
フォーク
14
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    Happy-Technologies-LLCがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Mcp Server」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Happy-Technologies-LLC/happy-platform-skills/tree/main/skills/development/mcp-server
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Happy-Technologies-LLC/happy-platform-skills.git /tmp/happy-platform-skills
mkdir -p .claude/skills
cp -r /tmp/happy-platform-skills/skills/development/mcp-server .claude/skills/mcp-server
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでMcp Serverを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にMcp Serverを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Mcp Serverは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

ServiceNow as MCP Server

Overview

This skill covers setting up ServiceNow as a Model Context Protocol (MCP) server, enabling AI agents to interact with ServiceNow through a standardized protocol:

  • Understanding MCP architecture and how ServiceNow fits as a tool provider
  • Defining tool capabilities that expose ServiceNow operations to AI agents
  • Configuring authentication and authorization for secure agent access
  • Building resource endpoints that agents can discover and interact with
  • Implementing input validation and output formatting for agent consumption
  • Setting up logging, rate limiting, and monitoring for MCP interactions
  • Testing MCP tool definitions with AI agent platforms

When to use: When enabling AI agents (Claude, ChatGPT, Cursor, etc.) to interact with ServiceNow data and operations through the MCP standard, building a ServiceNow integration for AI-powered workflows, or creating a standardized API layer for multi-agent orchestration.

Prerequisites

  • Roles: admin, rest_api_explorer, web_service_admin
  • Plugins: com.glide.rest (REST API), com.snc.oauth (OAuth 2.0)
  • Access: Write access to sys_rest_api, sys_script_include, sys_properties, sys_oauth_entity tables
  • Knowledge: REST API design, OAuth 2.0, JSON Schema, MCP specification concepts
  • Related Skills: development/scripted-rest-apis for REST API development, security/acl-management for access control

Procedure

Step 1: Understand MCP Architecture

The Model Context Protocol defines a standard interface for AI agents to discover and use tools. ServiceNow acts as the MCP server, exposing capabilities that agents can invoke.

MCP ARCHITECTURE:

[AI Agent (Client)]
       |
       | MCP Protocol (JSON-RPC 2.0)
       |
[MCP Server (ServiceNow)]
       |
       +-- Tools: Operations the agent can perform
       |     +-- query_records: Search ServiceNow tables
       |     +-- create_record: Create new records
       |     +-- update_record: Modify existing records
       |     +-- run_flow: Trigger Flow Designer flows
       |
       +-- Resources: Data the agent can read
       |     +-- incident://INC0010001: Incident record
       |     +-- kb://KB0010001: Knowledge article
       |     +-- cmdb://ci/server001: Configuration item
       |
       +-- Prompts: Predefined interaction templates
             +-- incident-triage: Guide incident categorization
             +-- change-risk: Assess change request risk

Step 2: Design the Tool Schema

Define the MCP tools that expose ServiceNow operations.

Tool Definition Format (MCP Standard):

json
{
  "name": "sn_query_records",
  "description": "Query ServiceNow records from any table using encoded query syntax. Returns matching records with specified fields.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "table": {
        "type": "string",
        "description": "ServiceNow table name (e.g., incident, change_request, sys_user)"
      },
      "query": {
        "type": "string",
        "description": "Encoded query string (e.g., priority=1^state=2)"
      },
      "fields": {
        "type": "string",
        "description": "Comma-separated list of fields to return"
      },
      "limit": {
        "type": "integer",
        "description": "Maximum records to return (default 10, max 100)",
        "default": 10
      }
    },
    "required": ["table"]
  }
}

Core Tool Definitions:

Tool NamePurposeRequired ParamsOptional Params
sn_query_recordsSearch recordstablequery, fields, limit, order_by
sn_read_recordGet single recordtable, sys_idfields
sn_create_recordCreate recordtable, data
sn_update_recordUpdate recordtable, sys_id, data
sn_get_schemaGet table schematable
sn_run_flowTrigger a flowflow_id, inputs
sn_search_kbSearch knowledge basequerykb_id, limit
sn_add_commentAdd work note/commenttable, sys_id, texttype (work_note/comment)

Step 3: Create the Scripted REST API

Build the REST API endpoints that implement MCP tool operations.

MCP Approach:

Tool: SN-Create-Record
Parameters:
  table_name: sys_rest_api
  data:
    name: "MCP Server API"
    api_id: "mcp_server"
    namespace: "x_mcp"
    short_description: "Model Context Protocol server endpoint for AI agent integration"
    active: true
    requires_authentication: true

REST Approach:

POST /api/now/table/sys_rest_api
Body: {
  "name": "MCP Server API",
  "api_id": "mcp_server",
  "namespace": "x_mcp",
  "short_description": "Model Context Protocol server endpoint for AI agent integration",
  "active": "true",
  "requires_authentication": "true"
}

Step 4: Create Resource Endpoints

Build API resources for each MCP tool capability.

MCP Approach:

Tool: SN-Create-Record
Parameters:
  table_name: sys_rest_api_resource
  data:
    rest_api: [REST_API_SYS_ID]
    name: "Tools List"
    resource_path: "/tools/list"
    http_method: "GET"
    short_description: "Return list of available MCP tools and their schemas"
    script: |
      (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
        var tools = [];
        tools.push({
          name: 'sn_query_records',
          description: 'Query ServiceNow records from any table',
          inputSchema: {
            type: 'object',
            properties: {
              table: { type: 'string', description: 'Table name' },
              query: { type: 'string', description: 'Encoded query' },
              fields: { type: 'string', description: 'Fields to return' },
              limit: { type: 'integer', description: 'Max results', default: 10 }
            },
            required: ['table']
          }
        });
        // Add more tool definitions...
        response.setBody({ tools: tools });
      })(request, response);

Tool Execution Endpoint:

Tool: SN-Create-Record
Parameters:
  table_name: sys_rest_api_resource
  data:
    rest_api: [REST_API_SYS_ID]
    name: "Tools Call"
    resource_path: "/tools/call"
    http_method: "POST"
    short_description: "Execute an MCP tool with provided arguments"
    script: |
      (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
        var body = request.body.data;
        var toolName = body.name;
        var args = body.arguments || {};

        var handler = new x_mcp.MCPToolHandler();
        var result = handler.execute(toolName, args);

        response.setBody({
          content: [{
            type: 'text',
            text: JSON.stringify(result)
          }]
        });
      })(request, response);

Step 5: Implement the Tool Handler

Create a Script Include to handle MCP tool execution.

MCP Approach:

Tool: SN-Create-Record
Parameters:
  table_name: sys_script_include
  data:
    name: "MCPToolHandler"
    api_name: "x_mcp.MCPToolHandler"
    script: |
      var MCPToolHandler = Class.create();
      MCPToolHandler.prototype = {
        initialize: function() {},

        execute: function(toolName, args) {
          switch(toolName) {
            case 'sn_query_records':
              return this._queryRecords(args);
            case 'sn_read_record':
              return this._readRecord(args);
            case 'sn_create_record':
              return this._createRecord(args);
            case 'sn_update_record':
              return this._updateRecord(args);
            case 'sn_get_schema':
              return this._getSchema(args);
            default:
              return { error: 'Unknown tool: ' + toolName };
          }
        },

        _queryRecords: function(args) {
          var gr = new GlideRecord(args.table);
          if (!gr.canRead()) return { error: 'Access denied to table: ' + args.table };
          if (args.query) gr.addEncodedQuery(args.query);
          gr.setLimit(Math.min(args.limit || 10, 100));
          gr.query();
          var results = [];
          var fields = args.fields ? args.fields.split(',') : null;
          while (gr.next()) {
            var record = {};
            if (fields) {
              fields.forEach(function(f) {
                record[f.trim()] = gr.getDisplayValue(f.trim());
              });
            } else {
              record.sys_id = gr.getUniqueValue();
              record.display_value = gr.getDisplayValue();
            }
            results.push(record);
          }
          return { records: results, count: results.length };
        },

        _readRecord: function(args) {
          var gr = new GlideRecord(args.table);
          if (!gr.canRead()) return { error: 'Access denied' };
          if (gr.get(args.sys_id)) {
            var record = {};
            var fields = args.fields ? args.fields.split(',') : null;
            if (fields) {
              fields.forEach(function(f) {
                record[f.trim()] = gr.getDisplayValue(f.trim());
              });
            }
            return { record: record };
          }
          return { error: 'Record not found' };
        },

        type: 'MCPToolHandler'
      };
    access: "public"
    active: true

Step 6: Configure Authentication

Set up OAuth 2.0 for secure agent authentication. Provision authentication material through an approved local credential manager or deployment secret store outside the model context. Never ask an agent to collect it, place it in a tool call, generate it in documentation, or add it to shell arguments or client JSON.

MCP Approach:

Tool: SN-Query-Table
Parameters:
  table_name: sys_oauth_entity
  query: type=client^active=true
  fields: sys_id,name,client_id,redirect_url,token_lifetime,refresh_token_lifetime
  limit: 10

Create OAuth Application:

Tool: SN-Create-Record
Parameters:
  table_name: sys_oauth_entity
  data:
    name: "MCP Agent OAuth Client"
    type: "client"
    client_id: "mcp_agent_client"
    redirect_url: "https://agent.example.com/callback"
    token_lifetime: 1800
    refresh_token_lifetime: 86400
    active: true
    comments: "OAuth client for MCP-compliant AI agents"

Authentication Flow:

  1. An administrator registers the client metadata in ServiceNow.
  2. An approved local credential helper performs the selected OAuth exchange outside the conversation and model context.
  3. The integration transport supplies the resulting authentication state without logging it.
  4. ServiceNow validates the request and applies the integration user's ACL context.

Step 7: Implement Access Controls

Configure ACLs and rate limits for MCP endpoints.

Table-Level Access Control:

Tool: SN-Query-Table
Parameters:
  table_name: sys_security_acl
  query: name=sys_rest_api^operation=execute
  fields: sys_id,name,operation,condition,role
  limit: 10

Rate Limiting Configuration:

Tool: SN-Create-Record
Parameters:
  table_name: sys_properties
  data:
    name: "x_mcp.rate_limit.per_minute"
    value: "60"
    description: "Maximum MCP API calls per minute per client"
    type: "integer"

Access Control Matrix:

ToolMinimum RoleTable ACL CheckRate Limit
sn_query_recordsitilTable read ACL60/min
sn_read_recorditilTable read ACL60/min
sn_create_recorditilTable create ACL30/min
sn_update_recorditilTable write ACL30/min
sn_get_schemaitilNone10/min
sn_run_flowflow_operatorFlow ACL10/min

Step 8: Implement Input Validation

Add validation to prevent misuse and ensure data quality.

VALIDATION RULES:

Table Name Validation:
- Must exist in sys_db_object
- Must not be in blocklist (sys_user_password, sys_certificate, etc.)
- Must be accessible to the authenticated user

Query Validation:
- Maximum query length: 2000 characters
- No script injection (block javascript: in queries for non-admin)
- Validate encoded query syntax

Field Validation:
- Fields must exist on the target table
- Sensitive fields filtered (password, token, secret fields)

Limit Validation:
- Maximum 100 records per query
- Default 10 if not specified

Data Validation (create/update):
- Validate field types match expected values
- Enforce mandatory field requirements
- Sanitize string inputs

Step 9: Set Up Logging and Monitoring

Configure logging for all MCP interactions.

MCP Approach:

Tool: SN-Create-Record
Parameters:
  table_name: sys_properties
  data:
    name: "x_mcp.logging.enabled"
    value: "true"
    description: "Enable logging for all MCP API interactions"
    type: "boolean"

Log Entry Structure:

MCP INTERACTION LOG:
- Timestamp: [ISO 8601]
- Client ID: [OAuth client]
- Tool: [tool_name]
- Arguments: [sanitized args]
- Response Status: [success/error]
- Response Time: [ms]
- Records Affected: [count]
- User Context: [authenticated user]

Step 10: Test MCP Integration

Validate the MCP server with agent platforms.

Test Tool Listing: Connect through an MCP client whose transport authentication is already configured by the local runtime, then inspect its advertised tool list.

Test Tool Execution: Invoke a low-risk, read-only schema or query tool through that MCP client. Verify allowlisting, ACL enforcement, rate limiting, sanitized logging, and response formatting. If a raw transport probe is indispensable, use an organization-approved local credential helper and keep all authentication state outside the command line and generated documentation.

Tool Usage

ToolPurposeWhen to Use
SN-Create-RecordCreate REST APIs, resources, script includesBuilding MCP server components
SN-Update-RecordModify API configurations, update scriptsIterating on MCP implementation
SN-Query-TableFind existing APIs, ACLs, OAuth configsDiscovery and validation
SN-Get-Table-SchemaDiscover table fields for tool schemasSchema generation
SN-Get-RecordReview specific API or script detailsDebugging and verification

Best Practices

  1. Follow MCP specification strictly -- ensure tool schemas match the MCP JSON Schema format
  2. Use OAuth 2.0 client credentials for server-to-server agent authentication
  3. Implement table allowlisting -- explicitly define which tables agents can access
  4. Never expose sensitive tables -- block access to credential, certificate, and password tables
  5. Rate limit aggressively -- AI agents can generate high request volumes
  6. Log all interactions -- maintain audit trail for security and debugging
  7. Return display values -- agents work better with human-readable data
  8. Implement pagination -- use cursor-based pagination for large result sets
  9. Version your API -- include version in resource path for backward compatibility
  10. Test with multiple agent platforms -- ensure compatibility across Claude, ChatGPT, etc.
  11. Keep large reference corpora optional -- use live/source-backed lookup by default and make local indexing, SQLite, embeddings, and vector search explicit opt-ins

Troubleshooting

IssueCauseResolution
401 UnauthorizedOAuth token expired or invalidRefresh token; verify client credentials; check token lifetime
403 ForbiddenUser lacks table or API ACLVerify roles assigned to OAuth user; check table ACLs
Tool not foundTool name mismatch between client and serverVerify tool names in tools/list response match client configuration
Empty resultsQuery syntax incorrect or no matching recordsTest query in ServiceNow directly; check encoded query syntax
Timeout on large queriesQuery returns too many recordsReduce limit; add more specific query conditions
Script error in tool handlerRuntime exception in Script IncludeCheck system logs (syslog); add error handling in handler scripts

Examples

Example 1: Basic Read-Only MCP Server

Scenario: Set up a minimal MCP server for read-only incident querying.

Tools exposed:

  • sn_query_incidents - Search incidents
  • sn_read_incident - Get incident details
  • sn_search_kb - Search knowledge base

Example 2: Full ITSM MCP Server

Scenario: Complete ITSM MCP server with create/update capabilities.

Tools exposed:

  • Query: incidents, changes, problems, CIs
  • Create: incidents, change requests
  • Update: incident state, assignment, priority
  • Actions: add work notes, trigger flows
  • Knowledge: search and retrieve KB articles

Example 3: Scoped MCP Server for HR

Scenario: Department-scoped MCP server for HR service delivery.

Tools exposed:

  • hr_query_cases - Search HR cases (filtered to requester's own cases)
  • hr_create_case - Submit new HR case
  • hr_search_policies - Search HR policy knowledge base
  • hr_check_benefits - Query benefits enrollment status

Access controls:

  • Only hr_case table accessible
  • Users can only see their own cases
  • Create limited to specific case categories

Related Skills

  • development/scripted-rest-apis - Building REST APIs in ServiceNow
  • security/acl-management - Configuring access control lists
  • admin/application-scope - Scoped application development
  • genai/build-agent - Building AI agents that consume MCP tools
  • genai/skill-kit-custom - Custom Now Assist skill development
  • development/servicenow-docs-mcp - ServiceNowDocs search and optional local indexing for Happy Platform MCP

よくある質問

AIスキル「Mcp Server」では何ができますか?

Set up ServiceNow as an MCP (Model Context Protocol) server defining tool capabilities, authentication, resource endpoints, and integration patterns for AI agents

TypingMindでMcp Serverを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Mcp Serverはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにMcp Serverをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Happy-Technologies-LLC/happy-platform-skills/tree/main/skills/development/mcp-serverを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Mcp Serverを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Mcp Serverで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもMcp Serverを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Mcp Server」は無料ですか?

はい。Happy-Technologies-LLCがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇