server-mcp

nagareproject/server-mcp

3.2

If you are the rightful owner of server-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Nagare Model Context Protocol server provides a flexible and efficient way to manage and interact with various resources, tools, and prompts through a standardized protocol.

Tools
1
Resources
0
Prompts
0

==================================== Nagare Model Context Protocol server

Features:

  • Available capabilities:

    • tools (with services injection)
    • resources (direct and template)
    • prompts
    • optional completions for resources and prompts arguments
  • Compliance to protocol revision 2024-11-05

  • Streamable "stateless" HTTP and STDIO protocols support

  • Admin commands for discovery and invocation of Streamable HTTP server methods

Protocols

Streamable HTTP

The application listens to url (/ by default)

.. code:: ini

[application]
name = ...
url = '/mcp'

STDIO

The publisher must be mcp-stdio, installed from nagare-publishers-mcp-stdio package

To not interfer with stdout communications, don't print and configure loggers to not emit to stdout:

.. code:: ini

[publisher]
type = mcp-stdio

[logging]
  [[logger]]
    [[[root]]]
    handlers = root

  [[handlers]]
    [[[root]]]
    class = logging.FileHandler
    args = "('/tmp/mcp.log', 'w')"

MCP server example

.. code:: python

import time

from nagare.server.mcp_application import MCPApp, tool, resource, prompt


class App(MCPApp):
    pass


# Tools
# -----

@tool(description='n1 + n2')
def add(a: int, b: int):
    """Add two numbers."""
    return a + b

# Resources
# ---------

@resource()
def resource1(uri, name):
    return 'Resource #1'

@resource(uri='r1')
def resource1_1(uri, name):
    return 'Hello', 'world!'

@resource('r2', name='r2', mime_type='application/octet-stream')
def resource2(uri, name):
    return b'Resource #2'

@resource(uri='r3', name='r3', mime_type='text/plain')
def resource3(uri, name):
    return open('/tmp/f.py')

@resource(mime_type='application/pdf')
def resource4(uri, name):
    return open('/tmp/doc.pdf', 'rb')

def complete_city(city):
    return [name for name in ['paris', 'new-york', 'sao-paulo', 'sidney'] if name.startswith(city.lower())]

@resource('weather://{city}/current', 't1', completions={'city': complete_city)
def template1(uri, name, city):
    return 'Weather for city {}'.format(city)

# Prompts
# -------

@prompt()
def prompt1(code, language='unknown'):
    return f'Explain how this {language} code works:\n\n{code}'

Admin commands

.. code:: sh

nagare mcp info http://127.0.0.1:8080

nagare mcp tools list http://127.0.0.1:8080

nagare mcp tools call add -p a=10 -p b=20 http://127.0.0.1:8080

nagare mcp resources list http://127.0.0.1:8080

nagare mcp resources read <uri> [-n <resource_index>] http://127.0.0.1:8080

nagare mcp prompts list http://127.0.0.1:8080

nagare mcp prompts get prompt1 -p language=python -p code='def fibo(): ...' http://127.0.0.1:8080

.. note::

All ``mcp`` subcommands accept several ``--root <name> <uri>`` arguments to define client roots