cd /news/ai-agents/deploying-snowflake-cortex-agent-and… · home topics ai-agents article
[ARTICLE · art-136768] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Deploying Snowflake Cortex Agent and Knowledge Graph with ServiceNow MCP Server

A developer documented an architecture that connects Claude Code to both Snowflake and ServiceNow through ServiceNow's MCP Server, exposing a subflow that invokes a Snowflake Cortex Agent and a ServiceNow Knowledge Graph as callable tools. The setup uses OAuth authentication between the two platforms and a Snowflake Semantic View so a single agent can answer questions spanning hardware assets in Snowflake and software assets in ServiceNow without the user knowing where the data lives.

by read14 min views1 publishedSep 22, 2026

ServiceNow provides a feature called MCP Server. It allows various capabilities registered in ServiceNow, such as flows and knowledge graphs, to be exposed as callable tools that AI agents such as Claude Code can invoke directly.

This article documents the steps used to build the following environment:

The final objective is to let a user ask a single AI agent a question such as, “What assets are managed by Tim?” and receive an answer spanning both the hardware assets in Snowflake and the software assets in ServiceNow. The advantage of this architecture is that users do not need to know where the data is stored, whether in Snowflake or ServiceNow.

All instance URLs and account names in this article have been replaced with placeholders such as <your-instance>. When implementing this architecture, replace them with the values for your own environment.

Claude Code (MCP Client)
        │  MCP protocol (OAuth authentication)
        ▼
ServiceNow
 ├─ MCP Server (gateway for tools)
 │   ├─ Tool: Subflow ── Invokes Snowflake Cortex Agent
 │   └─ Tool: Knowledge Graph ── Searches data in ServiceNow
 │
 └─ Snowflake, accessed through the subflow
      ├─ Cortex Agent
      └─ Semantic View (HARDWARE / ADMIN tables)

Before proceeding with the implementation, this section summarizes the terms used throughout the article. Return here if you encounter an unfamiliar term.

Term Description
MCP (Model Context Protocol) A standard protocol that allows AI agents to invoke external tools and data sources. An MCP Server provides tools, while an MCP Client, Claude Code in this example, consumes them.
Cortex Agent An AI agent capability provided by Snowflake. It receives a natural-language query, uses a Semantic View to construct SQL, retrieves data from tables, and returns an answer.
Semantic View A definition that adds business meaning to table columns and relationships, such as identifying an administrator name or an asset name. By using a Semantic View, Cortex Agent can construct SQL from natural language without directly relying on the physical table structure.
ServiceNow Knowledge Graph A ServiceNow capability that connects tables through edges and makes the resulting graph structure searchable using natural language. Within ServiceNow, it plays a role similar to the combination of a Snowflake Semantic View and Cortex Agent.
Subflow A reusable unit of processing created in ServiceNow Flow Designer and invoked by other flows. In this implementation, the Cortex Agent invocation is encapsulated in a subflow.

To use Cortex Agent, first create an entry point in Snowflake that accepts OAuth authentication from ServiceNow. You must also create the Semantic View that gives business meaning to the data, as well as a runtime user and the permissions required to query the agent.

Open a Snowsight worksheet using the ACCOUNTADMIN role and run the following SQL. This configuration allows Snowflake to accept OAuth authentication from ServiceNow.

-- 01. OAuth settings
USE ROLE ACCOUNTADMIN;
CREATE OR REPLACE SECURITY INTEGRATION _cortex_oauth_2
  TYPE = OAUTH
  ENABLED = TRUE
  OAUTH_CLIENT = CUSTOM
  OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
  OAUTH_REDIRECT_URI = 'https://<your-instance>.service-now.com/oauth_redirect.do'
  OAUTH_ISSUE_REFRESH_TOKENS = TRUE
  OAUTH_REFRESH_TOKEN_VALIDITY = 7776000 -- Refresh-token lifetime in seconds, up to 90 days
  COMMENT = 'OAuth integration for ServiceNow Cortex Agent Integration'
;

OAUTH_CLIENT_TYPE = 'CONFIDENTIAL' assumes that the client secret can be stored securely on the ServiceNow server side. A PUBLIC client is used for environments such as browsers or mobile applications where a secret cannot be protected. Because this implementation is a server-to-server integration, CONFIDENTIAL is selected.

After creating the security integration, retrieve the Client ID and Client Secret.

-- 02. Check the Client Secret and Client ID
SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('_CORTEX_OAUTH_2');

Keep these values available because they will be used in the ServiceNow Application Registry configuration.

Create the database and schema that will contain the managed data.

USE ROLE SYSADMIN;
CREATE DATABASE management;
CREATE SCHEMA hardware;

Create the following two tables in this schema and load the sample data.

ADMIN: Contains administrator IDs and administrator names.

admin_id admin_name
IT0001 Tim
IT0002 Chester
IT0003 Arlon
IT0004 Michel
IT0005 Lick
IT0006 Len
IT0007 Eathon

HARDWARE: Contains asset names, descriptions, vendors, administrator IDs, and related information.

admin_id asset_name vender description
IT0001 MacBook Pro 14 Apple Laptop for sales and proposal activities
IT0002 Dell Latitude 7450 Dell Windows laptop for internal business operations
IT0003 ThinkPad X1 Carbon Lenovo Laptop for data analysis and customer support
IT0004 Surface Laptop 7 Microsoft PC for meetings and presentations
IT0005 ProBook 440 G11 HP PC for general administration and remote work
IT0006 iPhone 16 Apple Smartphone for business communication and multi-factor authentication
IT0007 Galaxy Tab S10 Samsung Tablet for on-site viewing and mobile approvals
IT0001 Dell UltraSharp U2723QE Dell 27-inch external monitor for remote work
IT0003 MX Keys S Logitech Wireless keyboard for data entry
IT0006 Jabra Evolve2 65 Jabra Wireless headset for online meetings

Create a Semantic View so that the loaded table data can be queried using natural language.

MANAGEMENT.HARDWARE.ADMIN and MANAGEMENT.HARDWARE.HARDWARE as the tables.SV_HARDWARE_ADMIN. MANAGEMENT.HARDWARE. In the editor for SV_HARDWARE_ADMIN, configure the following:

ADMIN_ID columns in the two tables. This allows the agent to understand which administrator is responsible for each asset. Under Verified queries, register representative questions and their corresponding SQL statements in advance. This is an important way to improve the agent's response accuracy. It effectively teaches the agent an FAQ with model answers.

Question: What hardware assets are managed by each administrator?

SQL:

  SELECT a.ADMIN_NAME, h.ASSET_NAME, h.DESCRIPTION, h.VENDER
  FROM admin AS a
  JOIN hardware AS h ON a.ADMIN_ID = h.ADMIN_ID;

Next, create the agent that provides the external endpoint and selects the appropriate tool.

SEARCH_AGENT in Under Instructions, configure:

Under Tools, select Add semantic view and add the previously created SV_HARDWARE_ADMIN. This allows the agent to access data safely through the business definitions in the Semantic View rather than writing SQL without semantic context.

Finally, use Preview to test a question such as “Check the hardware managed by Tim” and verify that the expected answer is returned.

Grant the end user connecting from ServiceNow permission to execute Cortex Agent and access the required resources. A dedicated role and service account are used to follow the principle of least privilege, exposing only the permissions needed for the external integration. Using an administrator role for the ServiceNow connection could permit unintended operations.

-- 04. Create the role and grant permissions
USE ROLE SECURITYADMIN;

CREATE ROLE cortex_agent_hardware_search;
GRANT DATABASE ROLE SNOWFLAKE.CORTEX_AGENT_USER TO ROLE cortex_agent_hardware_search;
GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE cortex_agent_hardware_search;
GRANT USAGE ON DATABASE management TO ROLE cortex_agent_hardware_search;
GRANT USAGE ON SCHEMA management.hardware TO ROLE cortex_agent_hardware_search;
GRANT USAGE ON AGENT management.hardware.search_agent TO ROLE cortex_agent_hardware_search;
GRANT USAGE ON WAREHOUSE compute_wh TO ROLE cortex_agent_hardware_search;
GRANT USAGE ON DATABASE MANAGEMENT TO ROLE cortex_agent_hardware_search;
GRANT USAGE ON SCHEMA MANAGEMENT.HARDWARE TO ROLE CORTEX_AGENT_HARDWARE_SEARCH;
GRANT USAGE ON SEMANTIC VIEW MANAGEMENT.HARDWARE.SV_HARDWARE_ADMIN TO ROLE CORTEX_AGENT_HARDWARE_SEARCH;
GRANT SELECT ON SEMANTIC VIEW MANAGEMENT.HARDWARE.SV_HARDWARE_ADMIN TO ROLE CORTEX_AGENT_HARDWARE_SEARCH;
GRANT SELECT ON TABLE MANAGEMENT.HARDWARE.HARDWARE TO ROLE CORTEX_AGENT_HARDWARE_SEARCH;
GRANT SELECT ON TABLE MANAGEMENT.HARDWARE.ADMIN TO ROLE CORTEX_AGENT_HARDWARE_SEARCH;

-- Grant the role to the user
CREATE USER servicenow
    PASSWORD = '<your_password>'
    DEFAULT_ROLE = cortex_agent_hardware_search
    MUST_CHANGE_PASSWORD = FALSE
    COMMENT = 'Service account for ServiceNow integration';

GRANT ROLE cortex_agent_hardware_search TO USER servicenow;
GRANT ROLE sysadmin TO USER servicenow;

Use ServiceNow's standard OAuth integration capabilities to connect securely from ServiceNow to Snowflake. ServiceNow OAuth integration uses three layers, each with a different role:

Field Value
Name Snowflake Cortex Agents OAuth 2.0
Client ID Client ID issued by Snowflake
Client Secret Client Secret issued by Snowflake
Default Grant type Authorization Code
Authorization URL https://<your-account>.snowflakecomputing.com/oauth/authorize
Token URL https://<your-account>.snowflakecomputing.com/oauth/token-request
Redirect URL https://<your-instance>.service-now.com/oauth_redirect.do

This step registers the definition that tells ServiceNow which credentials to use when authenticating with Snowflake as an OAuth provider. It does not yet establish a connection or issue an authentication token.

Field Value
Name Snowflake Cortex Agents User Credential
OAuth Entity Profile Entity Profile for Snowflake Cortex Agents OAuth 2.0 created in Application Registry
Integration Type Personal

Save the configuration, then select Get OAuth Token to obtain an authentication token and store it in ServiceNow. At this point, the OAuth flow defined in Application Registry runs for the first time, including browser-based login and consent, and a token is issued.

Field Value
Name Snowflake OAuth Cortex Agents Alias
Field Value
Name Snowflake Cortex Agents HTTP Connection
Credential Snowflake Cortex Agents User Credential
Connection URL https://<your-account>.snowflakecomputing.com

Connection & Credential Alias provides an abstraction that Flow Designer can reference to determine which connection information to use for an HTTP request. If the destination or credential changes, the flow implementation does not need to be modified as long as the alias continues to resolve to the appropriate connection.

Snowflake Cortex Agent is invoked through the agent:run REST API.

Ask Snowflake Cortex Agent. Input variable definition

Label Type
user_prompt String

Action step definition

Step 1

/api/v2/databases/management/schemas/hardware/agents/search_agent:run

  {
    "stream": false,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "{{input user_prompt}}"
          }
        ]
      }
    ]
  }

Step 2

<step1 cortex agent action - response_body> <step1 cortex agent action - status_code>

(function execute(inputs, outputs) {
  if (inputs.status_code != 200) {
    outputs.error = "Error: HTTP " + inputs.status_code + " - " + inputs.response_body;
    outputs.answer = "";
    return;
  }

  try {
    var response = JSON.parse(inputs.response_body);
    var answerText = "";

    // Extract text from the content array in the non-streaming response
    if (response.content && response.content.length > 0) {
      for (var i = 0; i < response.content.length; i++) {
        if (response.content[i].type === "text") {
          answerText += response.content[i].text;
        }
      }
    }

    outputs.answer = answerText;
    outputs.error = "";
  } catch (e) {
    outputs.error = "Failed to parse response: " + e.message;
    outputs.answer = "";
  }
})(inputs, outputs);

Action output variable definition

Label Type Value
answer String <step2 return output - answer>
error String <step2 return output - error>

Finally, select Publish.

The action is invoked through a subflow rather than used directly so that the execution user's context is preserved. Calls from MCP Server should execute while retaining the identity of the user who submitted the question. This behavior is controlled through the subflow's Run As setting.

Field Value
Name Hardware Search Cortex Agents Sub Flow
Run As User who initiates session

Input and output variables

user_prompt / Stringanswer / String and error / String Actions

<1 Ask Snowflake Cortex Agent - answer> <1 Ask Snowflake Cortex Agent - error> Select Test, enter What kind of hardware is managed by Tim?, and verify that the expected value is returned. Finally, select Publish.

Finally, configure permissions so that an external AI agent can invoke this subflow through an MCP Client.

security_admin.

Field Value
Type flow
Operation invoke_from_ai
Decision Type Allow If
Role snc_internal

The dedicated invoke_from_ai operation makes it possible to distinguish between execution by a person through the UI and execution by an AI agent through MCP. Calls from AI can therefore be allowed or restricted independently of ordinary flow execution permissions.

The ServiceNow subflow configuration is now complete.

Software asset information is stored in ServiceNow tables, so natural-language search is implemented differently from the Snowflake part of the architecture. ServiceNow Knowledge Graph defines relationships between tables as a graph, allowing the data to be traversed through natural-language queries.

Prepare an Excel file and import the following tables through App Engine Studio.

admin: When configuring the admin_id column, select software: When configuring the | admin_id | software_name | vendor | description | |---|---|---|---| | IT0001 | Microsoft 365 Apps | Microsoft | Productivity suite for document creation, email, and collaboration | | IT0002 | Slack | Salesforce | Business messaging and team communication platform | | IT0003 | Tableau Desktop | Salesforce | Data visualization and dashboard development software | | IT0004 | Microsoft Teams | Microsoft | Online meetings, chat, and collaboration software | | IT0005 | Adobe Acrobat Pro | Adobe | PDF creation, editing, and electronic document management | | IT0006 | Microsoft Authenticator | Microsoft | Multi-factor authentication and secure account access application | | IT0007 | ServiceNow Mobile | ServiceNow | Mobile access for workflow tasks, approvals, and service requests | | IT0001 | Salesforce Sales Cloud | Salesforce | Customer relationship management software for sales activities | | IT0003 | Visual Studio Code | Microsoft | Source code editor for development and data-related scripts | | IT0006 | Jabra Direct | Jabra | Device management software for Jabra headsets and firmware updates |

software admin graph. What kind of software is managed by Tim?, and verify that the expected result is returned. The ServiceNow Knowledge Graph configuration is now complete.

Field Value
Label assets-admin-ask
Short Description This MCP server manages the administrators of hardware and software assets. Hardware assets and administrators are stored in Snowflake, while software assets and administrators are stored in ServiceNow Knowledge Graph.

Under Tools, select Create Tool and create the following two tools. This configuration presents the Snowflake data and ServiceNow data to users as two tools within a single MCP Server.

OAuth authentication is also required when the MCP Client, Claude Code, connects to ServiceNow MCP Server. In this flow, ServiceNow accepts OAuth requests from an external client, so configure it as an inbound integration.

Field Value
Name assets_admin_ask
Provider Name ServiceNow
Redirect URLs http://localhost:8080/callback

When Claude Code connects to a remote MCP Server through OAuth, it starts a temporary local web server to receive the authorization callback and token. By default, a random port may be used. Because a fixed redirect URL must be registered in the ServiceNow inbound integration in advance, use the --callback-port option to fix the port number.

This implementation uses port 8080. Add the following URL to Redirect URLs in the assets_admin_ask inbound integration created above:

http://localhost:8080/callback

The ServiceNow-side preparation is now complete. Finally, configure Claude Code through its VS Code extension and connect to the MCP Server in ServiceNow.

claude mcp add Using the Client ID and Client Secret issued for the inbound integration, register the MCP Server through the Claude Code CLI.

claude mcp add --transport http \
  --client-id <Client ID issued by the inbound integration> \
  --client-secret \
  --callback-port 8080 \
  --scope user \
  servicenow-mcp \
  https://<your-instance>.service-now.com/sncapps/mcp-server/mcp/<mcp-server-name>

--client-secret without a value and enter the secret interactively when prompted, preventing it from being stored in shell history.--scope user registers the server as a --scope is omitted, the configuration is local to the project and will not be visible to Claude Code sessions started from another directory.<mcp-server-name> is the path name corresponding to the server created in MCP Server Console, in this example assets-admin-ask. This command only registers the configuration. It does not open a browser at this stage. The OAuth authorization flow is started explicitly in the next step.

Check the authentication state of the registered server with:

claude mcp list

If servicenow-mcp is displayed as ! Needs authentication, the configuration has been registered but authentication has not yet been completed. To begin authentication, run the following command in an interactive Claude Code session:

/mcp

Select servicenow-mcp from the list, then select Authenticate. A browser opens and displays the ServiceNow login and authorization page. After authorization, the browser is redirected to http://localhost:8080/callback, the token is passed to Claude Code, and authentication is completed.

Run claude mcp list again. If servicenow-mcp is displayed as ✔ Connected, the connection is complete.

Finally, ask for the software and hardware assets managed by Tim and verify that the correct results are returned. In Claude Code, the result should look similar to the following.

This implementation uses ServiceNow MCP Server to provide seamless natural-language access from a single AI agent, Claude Code, to two data sources with different storage locations and query mechanisms: Snowflake Cortex Agent for hardware asset management and ServiceNow Knowledge Graph for software asset management.

ServiceNow MCP Server makes it possible to invoke both native ServiceNow assets and external tools efficiently through a unified interface.

── more in #ai-agents 4 stories · sorted by recency
── more on @snowflake 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/deploying-snowflake-…] indexed:0 read:14min 2026-09-22 ·