Connecting an MCP Client to MCP Servers on a Neuron

The following list outlines the steps necessary to connect an arbitrary LLM AI Agent with support for the Model Context Protocol (MCP) to a Neuron®, and allow the agent to use the MCP Servers published by the Neuron. In this interoperation, the LLM Agent will act as an MCP Client, and the Neuron will host multiple MCP Servers, as this specific type of web services are called. These MCP Servers can be integrated with the Neuron itself, or be published by pluggable modules installed on the Neuron. For a list of MCP Servers available in the Neuron itself, see the API section, MCP subsection in the Neuron Documentation.

  1. The first step is to register the LLM MCP client with the Neuron. This can be done manually, by creating a User Account, or XMPP Account on the Neuron (both types can be used). This can also be done, as recommended by the Model Context Protocol itself, and its HTTPS binding, by using OAUTH2. If registering the client dynamically using OAUTH2, an XMPP account will be created for the client under the hood. The account will have no privileges by default.

  2. Regardless of which route is selected, the user account or XMPP account need to be assigned a corresponding role. An appropriate Role has to be defined first, if none exist. Access to MCP servers is authorized. Each MCP Server lists the privileges different features require in its documentation. MCP and OAUTH2 scopes are translated to required privileges in the Neuron. Each Role defines what privileges it has. And a User or XMPP account having a specific role has by extension the privileges held by any of its roles.

  3. Once the LLM Client is registered with the Neuron, and relevant privileges have been assigned, the MCP Client needs to connect to one or more MCP Servers. This is done by configuring the MCP Servers it has access to. The LLM Client then authenticates itself with the Neuron using OAUTH2 (or other available mechanism), and then connects to each MCP Server in turn. For a list of MCP Servers available on the Neuron, see the Neuron Documentation.

  4. For troubleshooting, Postman can be used to interact with the MCP Servers on the Neuron as well. Similar steps as mentioned above has to be taken with Postman, with the exception that Postman cannot register itself dynamically. An account has to be created manually on the Neuron first. Postman can then connect using OAUTH2, generating an access token that can then be used to access the different MCP Servers.

#tutorial, #mcp, #ai, #oauth


Customizing Function Callbacks when using ChatGPT

With the latest release of the TAG.XmppOpenAIBridge.package package (build time 2023-09-01) the ChatGPT OpenAI-integration supports function callbacks. You can both define functions the API can call via the API implementation, or via the script interface, as illustrated below. This makes it easier to integrate OpanAI functionality into your services, both .NET services hosted by the Neuron®, as well as Markdown and script-based services.

Custom function via chat

As an example of how to integrate custom functionality with ChatGPT, the XMPP <-> OpenAI bridge has added the following custom functions, to facilitate the presentation of non-text-based content:

  • ShowImage(Url[,Width[,Height[,Alt]]])
  • ShowImages(Images[])
  • ShowVideo(Url[,Title[,Width[,Height]]])
  • ShowYouTubeVideo(Url[,Title[,Width[,Height]]])
  • PlayAudio(Url[,Title])
  • ShareLink(Url[,Title])
  • ShareLinks(Links[])

An example conversation might look like:

Conversation1 Conversation2

Note: Test connections från lab.tagroot.io to ChatGPT have been removed, as test project has concluded. To use the XMPP<->OpenAI bridge, install the package above, and configure the service accordingly.

You can test ChatGPT via XMPP, by adding chatgpt@lab.tagroot.io to your contact list:

chatgpt@lab.tagroot.io
chatgpt@lab.tagroot.io

New script extensions

The following functions are available on systems with the TAG.XmppOpenAIBridge.package installed. A more detailed description about the OpenAI-related functions referenced in this section is available in the XmppOpenAIBridge repository.

Function Description
ChatGpt(Instruction[,Sender],Text[,Functions],History[,Preview]) Calls the chat completion API of OpenAI (ChatGPT). The Instruction argument contains initialization instructions. The optional Sender argument contains the JID of the sender. If not provided, the JID of the quick-login user will be used. Text is the chat message to send. Functions contains a single function definition or a vector of function definitions the API can call if it chooses to. History is a boolean parameter that indicates if the session history should be included in the query. The optional Preview argument indicates if intermediate content responses are previewed during the execution of the query. The response to the call will be an object containing a Content property with textual content, a Function property with function call information if available, including a Result property, containing any results from a function call. If a function call is requested, available function definitions or lambda expressions will be checked. If available, they will be called, with the arguments available from the API.
ChatGptConfigured() Checks if Chat GPT is configured correctly. It requires a Chat GPT<->XMPP Bridge node to be configured in the MeteringTology source, with the Node ID ChatGPT.
ChatGptArray(Name,Description,Required,ItemParameter) Creates an array parameter for callback functions. The ItemParameter argument contains definition of each item in the array.
ChatGptBoolean(Name,Description,Required) Creates a Boolean parameter for callback functions.
ChatGptEnum(Name,Description,Required,Values) Creates an enumeration parameter for callback functions. The Values argument contains a vector of strings representing the possible values the argument can take.
ChatGptFunction(Name,Description,Parameters) Creates a function definition for callback functions. The Parameters argument contains a vector of parameter definitions representing the arguments of the function.
ChatGptInteger(Name,Description,Required[,MultipleOf]) Creates an integer parameter for callback functions, possibly requiring it to be a multiple of a given base value.
ChatGptInteger(Name,Description,Required[,Min,MinInc,Max,MaxInc]) Creates an integer parameter for callback functions, possibly within a specified range, between Min and Max, specifying also if the endpoints are included or not.
ChatGptInteger(Name,Description,Required[,MultipleOf,Min,MinInc,Max,MaxInc]) Creates an integer parameter for callback functions, possibly requiring it to be a multiple of a given base value, as well as within a specified range, between Min and Max, specifying also if the endpoints are included or not.
ChatGptNumber(Name,Description,Required[,MultipleOf]) Creates a number (float-point) parameter for callback functions, possibly requiring it to be a multiple of a given base value.
ChatGptNumber(Name,Description,Required[,Min,MinInc,Max,MaxInc]) Creates a number (float-point) parameter for callback functions, possibly within a specified range, between Min and Max, specifying also if the endpoints are included or not.
ChatGptNumber(Name,Description,Required[,MultipleOf,Min,MinInc,Max,MaxInc]) Creates a number (float-point) parameter for callback functions, possibly requiring it to be a multiple of a given base value, as well as within a specified range, between Min and Max, specifying also if the endpoints are included or not.
ChatGptObject(Name,Description,Required,Properties) Creates an object parameter for callback functions. The Properties argument contains a vector of parameter definitions representing the properties of the object.
ChatGptString(Name,Description,Required[,Pattern]) Creates a string parameter for callback functions, having a regular expression to validate input.
ChatGptString(Name,Description,Required[,Format]) Creates a string parameter for callback functions, having a specific format, as given by the string format enumeration listed below.

Example:

ShowImage(Image):=
(
	Get(Image.Url) ??? "Image not available"
);

ShowImages(Images):=
(
	[foreach Image in Images do ShowImage(Image)]
);

R:=ChatGpt(
	"You help users find images on the Internet, representative of the queries made by the user.",
	"TestUser",
	"Can you find me some images of Kermit? If something is unclear, ask for additional information first. When ready to present images to the user, call available functions.",
	ChatGptFunction("ShowImages", "Displays an array of images to the user.", [
		ChatGptArray("Images", "Array of images to show.", true, 
			ChatGptObject("Image", "Information about an image.", true, [
				ChatGptString("Url", "URL to the image to show.", true),
				ChatGptInteger("Width","Width of image, in pixels.", false, 0, false, null, false),
				ChatGptInteger("Height","Height of image, in pixels.", false, 0, false, null, false),
				ChatGptString("Alt", "Alternative textual description of image, in cases the image cannot be shown.", false)]))]),
	false,
	true);

R.Function.Result[0]
Result
Result

Note: If running script with ChatGPT-services on a web server, you can use the associated script functions to push information asynchronously back to the web client using the PushEvent script function.

#new, #features, #api, #openai, #ai, #script


XMPP-OpenAI bridge now uses GPT-4

The TAG XMPP↔OpenAI bridge has now been upgraded to use GPT-4. A new package has been published. The Neuron® at lab.tagroot.io (a.k.a. the “Lab Neuron®”) has also been updated. Anyone connected to the OpenAI XMPP bot accounts can therefore now seamlessly chat using GPT-4.

Original article with links to the bot accounts (connect using a XMPP client, such as the TAG ID apps, or derivatives): https://lab.tagroot.io/Community/Post/OpenAI_integration_with_the_Neuron

#neuron, #api, #openai, #ai


Translations of smart contracts in LegalLab now using ChatGPT

LegalLab is a repository for creating smart contracts. It has a translation feature, which allows users to translate texts into multiple languages, facilitating the publishing of multi-lingual agreements for cross-domain interoperation. This function has been updated to use ChatGPT from OpenAI. (Previously, Microsoft Translator was used). ChatGPT is much slower than Microsoft Translator, but creates better translations. It is also better at maintaining the formatting of formatted texts, reducing proof-reading and correction times.

To use the new translation feature in LegalLab you need to create an OpenAI account, and get an access key. You paste this key into the OpenAI Key field. Then, when you add new languages to your contract, they get automatically translated for you.

LegalLab OpenAI Key Example.png
LegalLab OpenAI Key Example.png

#ai, #legallab, #new, #features


OpenAI integration with the Neuron

There now exists a new package that integrates the OpenAI API into the Neuron®. With this package, it is possible to create XMPP/OpenAI-bridges, as well as integrate AI-generated content into Markdown. The package is openly available via the TAG Neuron network, and the code is available publicly on GitHub.

Package details

Below are information on how to install the package on your Neuron®s. For information on how to build, compile and test the package, see the repository.

Package information
Package TAG.XmppOpenAIBridge.package
Installation key XGyd1kOAZX3KMhpKLDJ0swJ0Bxwg1lF6Z/DgRScfo/Ys0dxfr4u7U/ofd4zjL00jpi5MJAOIpISAa4982aef95d5daae27ccbbe3f12c38ac
Repository https://github.com/Trust-Anchor-Group/XmppOpenAIBridge

Note: Test connections från lab.tagroot.io to ChatGPT have been removed, as test project has concluded. To use the XMPP<->OpenAI bridge, install the package above, and configure the service accordingly.

Test chatting with an AI bot

The following OpenAI gateways have been defined, and are openly available for chat. If your chat application supports voice, the bot can answer questions recorded and sent as downloadable audio URLs. Scan the corresponding codes, or enter them manually, using the ID App or similar XMPP client app.

Open OpenAI-bridges available
JID Description
chatgpt@lab.tagroot.io ChatGPT-XMPP bridge with minimal instruction.
dalle256@lab.tagroot.io DALL-E-XMPP bridge generating 256x256 images.
dalle512@lab.tagroot.io DALL-E-XMPP bridge generating 512x512 images.
dalle1024@lab.tagroot.io DALL-E-XMPP bridge generating 1024x1024 images.
chatgpt@lab.tagroot.io
chatgpt@lab.tagroot.io
dalle256@lab.tagroot.io
dalle256@lab.tagroot.io
dalle512@lab.tagroot.io
dalle512@lab.tagroot.io
dalle1024@lab.tagroot.io
dalle1024@lab.tagroot.io

Markdown integration

You can use OpenAI in Markdown. On this Neuron, you can add text generated by OpenAI as follows:

```chatgpt,ChatGPT:Text example
What do you know about the XMPP protocol?
```

This generates the following text (block quotes added here for visibility only):

What do you know about the XMPP protocol?

You can add images from DALL-E, as follows:

```dalle512,DallE:A blue dragon on skates
A blue dragon on skates
```

This generates:

A blue dragon on skates

(You can use dalle256 for smaller images, or dalle1024 for larger images.)

#new, #features, #neuron, #api, #openai, #ai, #repository


Posts tagged #ai

No more posts with the given tag could be found. You can go back to the main view by selecting Home in the menu above.