logo

NJP

Agentic AI - Create MCP Client and access it from Virtual agent topic

New article articles in ServiceNow Community · Jun 26, 2025 · article

Configure MCP Client in ServiceNow

Pre-requisites

Midserver to run the mcp client, mcp server and ollama service to access llama 3.2 model

Install ServiceNow spoke which has the action to execute mcp client

Github repo which has required powershell scripts : anilvaranasi/nowmcpclientfiles

Github repo for scoped app : anilvaranasi/nowmcpclient

Midserver configuration

Install python to run MCP server and client.

Install Ollama to run llama3.2 model by running the command

Download files from gitrepo anilvaranasi/nowmcpclientfiles and upload to midserver in folder C:\mcp

Ollama server

Ensure that Ollama is up and running and it has llama3.2 model

ollama run llama3.2

VaranAwesomenow_0-1750956014493.png

VaranAwesomenow_1-1750956014495.png

MCP Server

Test MCP server by running the command python c:\mcp\server.py

VaranAwesomenow_2-1750956014495.png

VaranAwesomenow_3-1750956014498.png

MCP Client

Once MCP server is up and running and when it being called by MCP client by running the command python langchain_client2.py

VaranAwesomenow_4-1750956014499.png

VaranAwesomenow_5-1750956014502.png

ServiceNow configuration

Scoped app

MCP client is scoped app that contains required code base

VaranAwesomenow_6-1750956014505.png

VaranAwesomenow_7-1750956014520.png

ServiceNow Spoke Action

MCP Client

MCP client is called via Power shell action from ServiceNow.

VaranAwesomenow_8-1750956014533.png

VaranAwesomenow_9-1750956014536.png

Script output is sent as response to action

VaranAwesomenow_24-1750956067300.png

VaranAwesomenow_25-1750956067310.png

Virtual agent topic

VaranAwesomenow_26-1750956067318.png

Testing

Test the spoke

Test from action to check for connectivity and execution

VaranAwesomenow_27-1750956067325.png

VaranAwesomenow_28-1750956067330.png

VaranAwesomenow_29-1750956067333.png

MCP server

VaranAwesomenow_30-1750956067342.png

Test virtual agent

VaranAwesomenow_31-1750956067343.png

VaranAwesomenow_32-1750956067347.png

VaranAwesomenow_33-1750956067348.png

VaranAwesomenow_0-1750962496808.png

VaranAwesomenow_1-1750962496811.png

VaranAwesomenow_2-1750962496813.png

VaranAwesomenow_3-1750962496817.png

References:

https://medium.com/the-ai-forum/understanding-the-mcp-workflow-building-a-local-mcp-client-using-ollama-and-langchain-mcp-5997b8a5fded -> Original source code is taken from here

View original source

https://www.servicenow.com/community/developer-articles/agentic-ai-create-mcp-client-and-access-it-from-virtual-agent/ta-p/3301689