Skip to content

conorheffron/mcp-charity

Repository files navigation

mcp-charity

License: GPL v3

Python package

Pylint

Quick Start

Install Dependencies

pipenv install -r requirements.txt

Start MCP Server with FASTMCP (transport=STDIO, for CLI interface instead of HTTP / Postman)

pipenv run fastmcp run charity_server.py

Start MCP Server for Testing with recommended python init main process

pipenv run python3 charity_server.py

Testing

Test via CLI with curl (Note: Allows for sub string search values - direct match not required!)

curl --request POST \
  --url http://localhost:8000/mcp \
  --header 'accept: application/json, text/event-stream' \
  --header 'content-type: application/json' \
  --header 'mcp-session-id: my-test-session-124' \
  --data '{ "method": "tools/call", 
    "params": {
        "name": "query_charities", 
        "arguments": { 
            "charity_name": "", 
            "location": "Gal", 
            "cause": "" 
        } 
        }, 
        "jsonrpc": "2.0", 
        "id": 9}'

Response from curl

event: message
data: {
  "jsonrpc": "2.0",
  "id": 9,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "[{\"name\":\"Irish Cancer Society\",\"location\":\"Galway\",\"cause\":\"Health\"}]"
      }
    ],
    "isError": false
  }
}

Use Postman to connect & tests available app tools / end-points

  • Connect to MCP end-point /mcp
  • The test available tools, in this case, try query_charities tool postman

HTTP Endpoint

Corresponding Logs

fastmcp-logs

Request Body for POST request to query_charities tool

curl --request POST \
  --url http://localhost:8000/mcp \
  --header 'accept: application/json, text/event-stream' \
  --header 'content-type: application/json' \
  --header 'mcp-session-id: my-test-session-124' \
  --data '{ "method": "tools/call", 
  "params": {
      "name": "query_charities", 
      "arguments": { 
          "charity_name": "", 
          "location": "", 
          "cause": "Animals" } 
      }, 
      "jsonrpc": "2.0", 
      "id": 9 }'

Curl Response Body (Formatted where isError == false)

event: message
data: {
  "jsonrpc": "2.0",
  "id": 9,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "[{\"name\":\"Dogs Trust\",\"location\":\"Dublin\",\"cause\":\"Animals\"}]"
      }
    ],
    "isError": false
  }
}

Request Body for POST request to query_charities tool with invalid argument

curl --request POST   --url http://localhost:8000/mcp   --header 'accept: application/json, text/event-stream'   --header 'content-type: application/json'   --header 'mcp-session-id: my-test-session-124'   --data '{ "method": "tools/call", 
  "params": { "name": "query_charities", 
      "arguments": {   
          "causes": "9" 
      } 
  }, 
  "jsonrpc": "2.0", 
  "id": 9}'

ERROR Response (isError == true)

event: message
data: {
  "jsonrpc": "2.0",
  "id": 9,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "1 validation error for call[query_charities]\ncauses\n  Unexpected keyword argument [type=unexpected_keyword_argument, input_value='9', input_type=str]\n    For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument"
      }
    ],
    "isError": true
  }
}

About

Sample MCP server used to expose charity information in a flexible manner.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages