Skip to main content
DigiTransact AI Learning Centre

Module 3 of 4

Building and connecting a server

From a first tool to a working connection in a client.

Lesson 1

Start with one tool

Pick one narrow capability: read a file, search a small table, fetch a status. Write it, test it directly, then expose it.

The first version should be callable from a script without any model in the loop, so you know the logic is sound.

  • Test the function before the protocol.
  • Return plain data structures.
  • Log the call, not the secret.

Check yourself. Why test the tool without a model first?

Lesson 2

Transports and lifecycle

Local servers are launched by the client and speak JSON-RPC over stdio. Remote servers listen over Streamable HTTP and handle sessions.

The handshake negotiates protocol version and capabilities. A client should degrade gracefully if a server offers less.

  • stdout is the protocol channel: never print debug output there.
  • Send logs to stderr.
  • Close cleanly on shutdown.

Check yourself. What breaks if a stdio server prints to stdout?

Lesson 3

Connecting a client

Most clients read a JSON configuration listing servers, commands and environment variables. Add the server, restart, then confirm the tools appear.

Test one call from the client interface and read the server log for the same request.

  • Keep secrets in the environment, not the config file.
  • Use absolute paths.
  • One server per capability is easier to debug.

Check yourself. Where should an API key live?

Lesson 4

Shipping it

Pin dependencies, document the permissions, provide a health check and a way to revoke access. Treat the server as production software.

Version the tool schemas; changing one silently breaks clients.

  • Pin versions.
  • Document scopes and data touched.
  • Provide an audit log.

Check yourself. Why do tool schemas need versioning?