[{"data":1,"prerenderedAt":1868},["ShallowReactive",2],{"/open_source/best_practice/mcp_for_cozespace_and_tools":3,"surround-/open_source/best_practice/mcp_for_cozespace_and_tools":1853},{"id":4,"title":5,"avatar":6,"banner":6,"body":7,"category":6,"desc":6,"description":1846,"extension":1847,"links":6,"meta":1848,"navigation":6,"path":1849,"seo":1850,"stem":1851,"__hash__":1852},"docs/en/open_source/best_practice/mcp_for_cozespace_and_tools.md","Configuring Memos MCP in Coze Space",null,{"type":8,"value":9,"toc":1811},"minimark",[10,14,19,22,27,30,36,52,57,68,71,104,108,111,115,129,134,145,148,151,155,158,162,165,175,180,204,601,605,608,677,679,683,686,1596,1598,1602,1606,1611,1629,1633,1637,1654,1658,1662,1676,1680,1685,1704,1706,1710,1713,1727,1730,1776,1780,1783,1787,1791,1794,1807],[11,12,13],"p",{},"This guide helps you configure MemOS MCP service in platforms like Coze Space, enabling seamless integration between your agent and the memory system.",[15,16,18],"h2",{"id":17},"choose-an-mcp-deployment-method","Choose an MCP Deployment Method",[11,20,21],{},"MemOS provides two MCP deployment options. Choose based on your needs:",[23,24,26],"h3",{"id":25},"use-memos-cloud-service-recommended","Use MemOS Cloud Service (Recommended)",[11,28,29],{},"If you want to connect quickly without deploying your own server, MemOS official cloud service is recommended.",[11,31,32],{},[33,34,35],"strong",{},"Advantages:",[37,38,39,43,46,49],"ul",{},[40,41,42],"li",{},"✅ Out of the box, no deployment required",[40,44,45],{},"✅ High availability guarantees",[40,47,48],{},"✅ Automatic scaling and maintenance",[40,50,51],{},"✅ Supports multiple clients (Claude, Cursor, Cline, etc.)",[11,53,54],{},[33,55,56],{},"How to configure:",[11,58,59,60,67],{},"Visit ",[61,62,66],"a",{"href":63,"rel":64},"https://memos-docs.openmem.net/cn/mcp_agent/mcp/guide",[65],"nofollow","MemOS Cloud MCP Configuration Guide"," for detailed instructions.",[11,69,70],{},"Main steps:",[72,73,74,82,90],"ol",{},[40,75,76,77],{},"Register and get an API Key in ",[61,78,81],{"href":79,"rel":80},"https://memos-dashboard.memtensor.net/cn/apikeys/",[65],"MemOS API Console",[40,83,84,85,89],{},"Configure ",[86,87,88],"code",{},"@memtensor/memos-api-mcp"," service in your MCP client",[40,91,92,93,96,97,96,100,103],{},"Set environment variables (",[86,94,95],{},"MEMOS_API_KEY",", ",[86,98,99],{},"MEMOS_USER_ID",[86,101,102],{},"MEMOS_CHANNEL",")",[23,105,107],{"id":106},"deploy-mcp-service-yourself","Deploy MCP Service Yourself",[11,109,110],{},"If you need a private deployment or custom requirements, you can deploy MCP service on your own server.",[11,112,113],{},[33,114,35],{},[37,116,117,120,123,126],{},[40,118,119],{},"✅ Fully private data",[40,121,122],{},"✅ Configurable and customizable",[40,124,125],{},"✅ Full control of the service",[40,127,128],{},"✅ Suitable for internal enterprise use",[11,130,131],{},[33,132,133],{},"Prerequisites:",[37,135,136,139,142],{},[40,137,138],{},"Python 3.9+",[40,140,141],{},"Neo4j database (or another supported graph database)",[40,143,144],{},"HTTPS domain (required by platforms like Coze)",[11,146,147],{},"Continue reading for detailed deployment steps.",[149,150],"hr",{},[15,152,154],{"id":153},"self-hosted-mcp-service-configuration","Self-Hosted MCP Service Configuration",[11,156,157],{},"The content below applies to users who deploy MCP service themselves.",[15,159,161],{"id":160},"architecture","Architecture",[11,163,164],{},"Self-hosted MCP service uses the following architecture:",[166,167,172],"pre",{"className":168,"code":170,"language":171},[169],"language-text","Client (Coze/Claude, etc.)\n    ↓ [HTTPS]\nMCP Server (port 8002)\n    ↓ [HTTP calls]\nServer API (port 8001)\n    ↓\nMemOS Core Service\n","text",[86,173,170],{"__ignoreMap":174},"",[11,176,177],{},[33,178,179],{},"Component overview:",[37,181,182,192,198],{},[40,183,184,187,188,191],{},[33,185,186],{},"Server API",": provides REST APIs (",[86,189,190],{},"/product/*",") to handle memory CRUD",[40,193,194,197],{},[33,195,196],{},"MCP Server",": exposes the MCP protocol over HTTP and calls Server API to complete operations",[40,199,200,203],{},[33,201,202],{},"HTTPS reverse proxy",": platforms like Coze require HTTPS secure connections",[205,206,208,212,215,252,255,268,271,287,291,294,323,326,332,337,344,372,408,412,415,420,556,567,571,574,592,595],"steps",{"level":207},"3",[23,209,211],{"id":210},"step-1-start-server-api","Step 1: Start Server API",[11,213,214],{},"Server API is the backend for MCP service and provides actual memory management capabilities.",[166,216,220],{"className":217,"code":218,"language":219,"meta":174,"style":174},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","cd /path/to/MemOS\npython src/memos/api/server_api.py --port 8001\n","bash",[86,221,222,235],{"__ignoreMap":174},[223,224,227,231],"span",{"class":225,"line":226},"line",1,[223,228,230],{"class":229},"s2Zo4","cd",[223,232,234],{"class":233},"sfazB"," /path/to/MemOS\n",[223,236,238,242,245,248],{"class":225,"line":237},2,[223,239,241],{"class":240},"sBMFI","python",[223,243,244],{"class":233}," src/memos/api/server_api.py",[223,246,247],{"class":233}," --port",[223,249,251],{"class":250},"sbssI"," 8001\n",[11,253,254],{},"Verify whether Server API is running:",[166,256,258],{"className":217,"code":257,"language":219,"meta":174,"style":174},"curl http://localhost:8001/docs\n",[86,259,260],{"__ignoreMap":174},[223,261,262,265],{"class":225,"line":226},[223,263,264],{"class":240},"curl",[223,266,267],{"class":233}," http://localhost:8001/docs\n",[11,269,270],{},"If it returns the API documentation page, startup succeeded.",[272,273,274],"note",{},[11,275,276,279,282,283,286],{},[33,277,278],{},"Configuration file",[280,281],"br",{},"\nServer API loads configuration automatically. Ensure Neo4j and other dependencies are configured correctly. You can refer to ",[86,284,285],{},"examples/data/config/tree_config_shared_database.json"," as an example configuration.",[23,288,290],{"id":289},"step-2-start-mcp-http-service","Step 2: Start MCP HTTP Service",[11,292,293],{},"Start MCP service in another terminal:",[166,295,297],{"className":217,"code":296,"language":219,"meta":174,"style":174},"cd /path/to/MemOS\npython examples/mem_mcp/simple_fastmcp_serve.py --transport http --port 8002\n",[86,298,299,305],{"__ignoreMap":174},[223,300,301,303],{"class":225,"line":226},[223,302,230],{"class":229},[223,304,234],{"class":233},[223,306,307,309,312,315,318,320],{"class":225,"line":237},[223,308,241],{"class":240},[223,310,311],{"class":233}," examples/mem_mcp/simple_fastmcp_serve.py",[223,313,314],{"class":233}," --transport",[223,316,317],{"class":233}," http",[223,319,247],{"class":233},[223,321,322],{"class":250}," 8002\n",[11,324,325],{},"After MCP service starts, it will show information similar to:",[166,327,330],{"className":328,"code":329,"language":171},[169],"╭──────────────────────────────────────────────────╮\n│       MemOS MCP via Server API                   │\n│       Transport:   HTTP                          │\n│       Server URL:  http://localhost:8002/mcp     │\n╰──────────────────────────────────────────────────╯\n",[86,331,329],{"__ignoreMap":174},[11,333,334],{},[33,335,336],{},"Environment variable configuration (optional):",[11,338,339,340,343],{},"You can configure the Server API address via a ",[86,341,342],{},".env"," file or environment variables:",[166,345,347],{"className":217,"code":346,"language":219,"meta":174,"style":174},"export MEMOS_API_BASE_URL=\"http://localhost:8001/product\"\n",[86,348,349],{"__ignoreMap":174},[223,350,351,355,359,363,366,369],{"class":225,"line":226},[223,352,354],{"class":353},"spNyl","export",[223,356,358],{"class":357},"sTEyZ"," MEMOS_API_BASE_URL",[223,360,362],{"class":361},"sMK4o","=",[223,364,365],{"class":361},"\"",[223,367,368],{"class":233},"http://localhost:8001/product",[223,370,371],{"class":361},"\"\n",[272,373,374,382,402],{},[11,375,376,379,381],{},[33,377,378],{},"Tool list",[280,380],{},"\nMCP service provides the following tools:",[37,383,384,390,396],{},[40,385,386,389],{},[86,387,388],{},"add_memory",": add memory",[40,391,392,395],{},[86,393,394],{},"search_memories",": search memories",[40,397,398,401],{},[86,399,400],{},"chat",": chat with the memory system",[11,403,404,405],{},"For the full tool list, see ",[86,406,407],{},"examples/mem_mcp/simple_fastmcp_serve.py",[23,409,411],{"id":410},"step-3-configure-an-https-reverse-proxy","Step 3: Configure an HTTPS Reverse Proxy",[11,413,414],{},"Platforms like Coze require HTTPS. You need to set up an HTTPS reverse proxy (e.g., Nginx) to forward traffic to MCP service.",[11,416,417],{},[33,418,419],{},"Nginx configuration example:",[166,421,425],{"className":422,"code":423,"language":424,"meta":174,"style":174},"language-nginx shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","server {\n    listen 443 ssl http2;\n    server_name your-domain.com;\n    \n    ssl_certificate /path/to/cert.pem;\n    ssl_certificate_key /path/to/key.pem;\n    \n    location /mcp {\n        proxy_pass http://localhost:8002/mcp;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        \n        # SSE support\n        proxy_buffering off;\n        proxy_cache off;\n    }\n}\n","nginx",[86,426,427,432,437,443,449,455,461,466,472,478,484,490,496,502,508,514,520,526,532,538,544,550],{"__ignoreMap":174},[223,428,429],{"class":225,"line":226},[223,430,431],{},"server {\n",[223,433,434],{"class":225,"line":237},[223,435,436],{},"    listen 443 ssl http2;\n",[223,438,440],{"class":225,"line":439},3,[223,441,442],{},"    server_name your-domain.com;\n",[223,444,446],{"class":225,"line":445},4,[223,447,448],{},"    \n",[223,450,452],{"class":225,"line":451},5,[223,453,454],{},"    ssl_certificate /path/to/cert.pem;\n",[223,456,458],{"class":225,"line":457},6,[223,459,460],{},"    ssl_certificate_key /path/to/key.pem;\n",[223,462,464],{"class":225,"line":463},7,[223,465,448],{},[223,467,469],{"class":225,"line":468},8,[223,470,471],{},"    location /mcp {\n",[223,473,475],{"class":225,"line":474},9,[223,476,477],{},"        proxy_pass http://localhost:8002/mcp;\n",[223,479,481],{"class":225,"line":480},10,[223,482,483],{},"        proxy_http_version 1.1;\n",[223,485,487],{"class":225,"line":486},11,[223,488,489],{},"        proxy_set_header Upgrade $http_upgrade;\n",[223,491,493],{"class":225,"line":492},12,[223,494,495],{},"        proxy_set_header Connection \"upgrade\";\n",[223,497,499],{"class":225,"line":498},13,[223,500,501],{},"        proxy_set_header Host $host;\n",[223,503,505],{"class":225,"line":504},14,[223,506,507],{},"        proxy_set_header X-Real-IP $remote_addr;\n",[223,509,511],{"class":225,"line":510},15,[223,512,513],{},"        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n",[223,515,517],{"class":225,"line":516},16,[223,518,519],{},"        proxy_set_header X-Forwarded-Proto $scheme;\n",[223,521,523],{"class":225,"line":522},17,[223,524,525],{},"        \n",[223,527,529],{"class":225,"line":528},18,[223,530,531],{},"        # SSE support\n",[223,533,535],{"class":225,"line":534},19,[223,536,537],{},"        proxy_buffering off;\n",[223,539,541],{"class":225,"line":540},20,[223,542,543],{},"        proxy_cache off;\n",[223,545,547],{"class":225,"line":546},21,[223,548,549],{},"    }\n",[223,551,553],{"class":225,"line":552},22,[223,554,555],{},"}\n",[557,558,559],"warning",{},[11,560,561,564,566],{},[33,562,563],{},"HTTPS certificate",[280,565],{},"\nMake sure you use a valid SSL certificate. Self-signed certificates may not be accepted by platforms like Coze. You can use Let's Encrypt to obtain a free certificate.",[23,568,570],{"id":569},"step-4-test-mcp-service","Step 4: Test MCP Service",[11,572,573],{},"Use the client test script to verify the service:",[166,575,577],{"className":217,"code":576,"language":219,"meta":174,"style":174},"cd /path/to/MemOS\npython examples/mem_mcp/simple_fastmcp_client.py\n",[86,578,579,585],{"__ignoreMap":174},[223,580,581,583],{"class":225,"line":226},[223,582,230],{"class":229},[223,584,234],{"class":233},[223,586,587,589],{"class":225,"line":237},[223,588,241],{"class":240},[223,590,591],{"class":233}," examples/mem_mcp/simple_fastmcp_client.py\n",[11,593,594],{},"Example success output:",[166,596,599],{"className":597,"code":598,"language":171},[169],"Working FastMCP Client\n========================================\nConnected to MCP server\n\n  1. Adding memory...\n    Result: Memory added successfully\n  \n  2. Searching memories...\n    Result: [search result]\n  \n  3. Chatting...\n    Result: [AI response]\n\n✓ All tests completed!\n",[86,600,598],{"__ignoreMap":174},[15,602,604],{"id":603},"configure-mcp-in-coze-space","Configure MCP in Coze Space",[11,606,607],{},"After the service is deployed, configure the MCP connection in Coze Space.",[205,609,610,614,621,625,628,634,638,641,647,650,667],{"level":207},[23,611,613],{"id":612},"step-1-open-coze-space-and-go-to-the-tool-configuration-page","Step 1: Open Coze Space and go to the tool configuration page",[11,615,616],{},[617,618],"img",{"alt":619,"src":620},"Coze Space configuration page","https://cdn.memt.ai/static/memos/coze_space_1.png",[23,622,624],{"id":623},"step-2-add-a-custom-mcp-tool","Step 2: Add a custom MCP tool",[11,626,627],{},"Add a custom tool on the tool configuration page:",[11,629,630],{},[617,631],{"alt":632,"src":633},"Add a custom tool","https://cdn.memt.ai/static/memos/coze_space_2.png",[23,635,637],{"id":636},"step-3-configure-the-mcp-endpoint-url","Step 3: Configure the MCP endpoint URL",[11,639,640],{},"Configure the MCP endpoint URL with your HTTPS address:",[166,642,645],{"className":643,"code":644,"language":171},[169],"https://your-domain.com/mcp\n",[86,646,644],{"__ignoreMap":174},[11,648,649],{},"Available MCP tools:",[37,651,652,657,662],{},[40,653,654,656],{},[33,655,388],{},": add a new memory",[40,658,659,661],{},[33,660,394],{},": search existing memories",[40,663,664,666],{},[33,665,400],{},": memory-based chat",[272,668,669],{},[11,670,671,674,676],{},[33,672,673],{},"Test connection",[280,675],{},"\nAfter configuration, test whether MCP connection works in Coze. Ensure each tool can be called successfully.",[149,678],{},[15,680,682],{"id":681},"use-rest-api-directly-advanced","Use REST API Directly (Advanced)",[11,684,685],{},"For scenarios that require more flexible integration, you can call Server API’s REST endpoints directly.",[205,687,688,691,711,716,727,731,739,745,749,755,764,768,771,1178,1183,1186,1562,1566,1569,1575,1579,1582],{"level":207},[23,689,211],{"id":690},"step-1-start-server-api-1",[166,692,693],{"className":217,"code":218,"language":219,"meta":174,"style":174},[86,694,695,701],{"__ignoreMap":174},[223,696,697,699],{"class":225,"line":226},[223,698,230],{"class":229},[223,700,234],{"class":233},[223,702,703,705,707,709],{"class":225,"line":237},[223,704,241],{"class":240},[223,706,244],{"class":233},[223,708,247],{"class":233},[223,710,251],{"class":250},[11,712,713],{},[33,714,715],{},"Port notes",[37,717,718,721],{},[40,719,720],{},"Server API runs on port 8001 by default",[40,722,723,724,726],{},"Provides ",[86,725,190],{}," REST API endpoints",[23,728,730],{"id":729},"step-2-configure-custom-tools-in-coze-ide","Step 2: Configure custom tools in Coze IDE",[72,732,733,736],{},[40,734,735],{},"In Coze, choose the \"IDE plugin\" creation method",[40,737,738],{},"Configure requests to your deployed Server API service",[11,740,741],{},[617,742],{"alt":743,"src":744},"Coze IDE plugin configuration","https://cdn.memt.ai/static/memos/coze_tools_1.png",[23,746,748],{"id":747},"step-3-implement-the-add_memory-tool","Step 3: Implement the add_memory tool",[11,750,751],{},[617,752],{"alt":753,"src":754},"Configure add_memory operation","https://cdn.memt.ai/static/memos/coze_tools_2.png",[11,756,757,760,761,763],{},[33,758,759],{},"Code example:"," configure and publish the ",[86,762,388],{}," operation in the IDE:",[11,765,766],{},[617,767],{"alt":753,"src":754},[11,769,770],{},"Full code is as follows:",[166,772,775],{"className":773,"code":774,"language":241,"meta":174,"style":174},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import json\nimport requests\nfrom runtime import Args\nfrom typings.add_memory.add_memory import Input, Output\n\ndef handler(args: Args[Input])->Output:\n    memory_content = args.input.memory_content\n    user_id = args.input.user_id\n    cube_id = args.input.cube_id\n    \n    # Call Server API add endpoint\n    url = \"https://your-domain.com:8001/product/add\"\n    payload = json.dumps({\n        \"user_id\": user_id,\n        \"messages\": memory_content,  # Supports string or message array\n        \"writable_cube_ids\": [cube_id] if cube_id else None\n    })\n    headers = {\n        'Content-Type': 'application/json'\n    }\n    \n    response = requests.post(url, headers=headers, data=payload, timeout=30)\n    response.raise_for_status()\n    \n    return response.json()\n",[86,776,777,786,793,806,834,840,876,897,915,933,937,943,958,976,994,1013,1045,1050,1060,1082,1086,1090,1143,1157,1162],{"__ignoreMap":174},[223,778,779,783],{"class":225,"line":226},[223,780,782],{"class":781},"s7zQu","import",[223,784,785],{"class":357}," json\n",[223,787,788,790],{"class":225,"line":237},[223,789,782],{"class":781},[223,791,792],{"class":357}," requests\n",[223,794,795,798,801,803],{"class":225,"line":439},[223,796,797],{"class":781},"from",[223,799,800],{"class":357}," runtime ",[223,802,782],{"class":781},[223,804,805],{"class":357}," Args\n",[223,807,808,810,813,816,818,820,823,825,828,831],{"class":225,"line":445},[223,809,797],{"class":781},[223,811,812],{"class":357}," typings",[223,814,815],{"class":361},".",[223,817,388],{"class":357},[223,819,815],{"class":361},[223,821,822],{"class":357},"add_memory ",[223,824,782],{"class":781},[223,826,827],{"class":357}," Input",[223,829,830],{"class":361},",",[223,832,833],{"class":357}," Output\n",[223,835,836],{"class":225,"line":451},[223,837,839],{"emptyLinePlaceholder":838},true,"\n",[223,841,842,845,848,851,855,858,861,864,867,870,873],{"class":225,"line":457},[223,843,844],{"class":353},"def",[223,846,847],{"class":229}," handler",[223,849,850],{"class":361},"(",[223,852,854],{"class":853},"sHdIc","args",[223,856,857],{"class":361},":",[223,859,860],{"class":357}," Args",[223,862,863],{"class":361},"[",[223,865,866],{"class":357},"Input",[223,868,869],{"class":361},"])->",[223,871,872],{"class":357},"Output",[223,874,875],{"class":361},":\n",[223,877,878,881,883,886,888,892,894],{"class":225,"line":463},[223,879,880],{"class":357},"    memory_content ",[223,882,362],{"class":361},[223,884,885],{"class":357}," args",[223,887,815],{"class":361},[223,889,891],{"class":890},"swJcz","input",[223,893,815],{"class":361},[223,895,896],{"class":890},"memory_content\n",[223,898,899,902,904,906,908,910,912],{"class":225,"line":468},[223,900,901],{"class":357},"    user_id ",[223,903,362],{"class":361},[223,905,885],{"class":357},[223,907,815],{"class":361},[223,909,891],{"class":890},[223,911,815],{"class":361},[223,913,914],{"class":890},"user_id\n",[223,916,917,920,922,924,926,928,930],{"class":225,"line":474},[223,918,919],{"class":357},"    cube_id ",[223,921,362],{"class":361},[223,923,885],{"class":357},[223,925,815],{"class":361},[223,927,891],{"class":890},[223,929,815],{"class":361},[223,931,932],{"class":890},"cube_id\n",[223,934,935],{"class":225,"line":480},[223,936,448],{"class":357},[223,938,939],{"class":225,"line":486},[223,940,942],{"class":941},"sHwdD","    # Call Server API add endpoint\n",[223,944,945,948,950,953,956],{"class":225,"line":492},[223,946,947],{"class":357},"    url ",[223,949,362],{"class":361},[223,951,952],{"class":361}," \"",[223,954,955],{"class":233},"https://your-domain.com:8001/product/add",[223,957,371],{"class":361},[223,959,960,963,965,968,970,973],{"class":225,"line":498},[223,961,962],{"class":357},"    payload ",[223,964,362],{"class":361},[223,966,967],{"class":357}," json",[223,969,815],{"class":361},[223,971,972],{"class":229},"dumps",[223,974,975],{"class":361},"({\n",[223,977,978,981,984,986,988,991],{"class":225,"line":504},[223,979,980],{"class":361},"        \"",[223,982,983],{"class":233},"user_id",[223,985,365],{"class":361},[223,987,857],{"class":361},[223,989,990],{"class":229}," user_id",[223,992,993],{"class":361},",\n",[223,995,996,998,1001,1003,1005,1008,1010],{"class":225,"line":510},[223,997,980],{"class":361},[223,999,1000],{"class":233},"messages",[223,1002,365],{"class":361},[223,1004,857],{"class":361},[223,1006,1007],{"class":229}," memory_content",[223,1009,830],{"class":361},[223,1011,1012],{"class":941},"  # Supports string or message array\n",[223,1014,1015,1017,1020,1022,1024,1027,1030,1033,1036,1039,1042],{"class":225,"line":516},[223,1016,980],{"class":361},[223,1018,1019],{"class":233},"writable_cube_ids",[223,1021,365],{"class":361},[223,1023,857],{"class":361},[223,1025,1026],{"class":361}," [",[223,1028,1029],{"class":229},"cube_id",[223,1031,1032],{"class":361},"]",[223,1034,1035],{"class":781}," if",[223,1037,1038],{"class":229}," cube_id ",[223,1040,1041],{"class":781},"else",[223,1043,1044],{"class":361}," None\n",[223,1046,1047],{"class":225,"line":522},[223,1048,1049],{"class":361},"    })\n",[223,1051,1052,1055,1057],{"class":225,"line":528},[223,1053,1054],{"class":357},"    headers ",[223,1056,362],{"class":361},[223,1058,1059],{"class":361}," {\n",[223,1061,1062,1065,1068,1071,1073,1076,1079],{"class":225,"line":534},[223,1063,1064],{"class":361},"        '",[223,1066,1067],{"class":233},"Content-Type",[223,1069,1070],{"class":361},"'",[223,1072,857],{"class":361},[223,1074,1075],{"class":361}," '",[223,1077,1078],{"class":233},"application/json",[223,1080,1081],{"class":361},"'\n",[223,1083,1084],{"class":225,"line":540},[223,1085,549],{"class":361},[223,1087,1088],{"class":225,"line":546},[223,1089,448],{"class":357},[223,1091,1092,1095,1097,1100,1102,1105,1107,1110,1112,1115,1117,1120,1122,1125,1127,1130,1132,1135,1137,1140],{"class":225,"line":552},[223,1093,1094],{"class":357},"    response ",[223,1096,362],{"class":361},[223,1098,1099],{"class":357}," requests",[223,1101,815],{"class":361},[223,1103,1104],{"class":229},"post",[223,1106,850],{"class":361},[223,1108,1109],{"class":229},"url",[223,1111,830],{"class":361},[223,1113,1114],{"class":853}," headers",[223,1116,362],{"class":361},[223,1118,1119],{"class":229},"headers",[223,1121,830],{"class":361},[223,1123,1124],{"class":853}," data",[223,1126,362],{"class":361},[223,1128,1129],{"class":229},"payload",[223,1131,830],{"class":361},[223,1133,1134],{"class":853}," timeout",[223,1136,362],{"class":361},[223,1138,1139],{"class":250},"30",[223,1141,1142],{"class":361},")\n",[223,1144,1146,1149,1151,1154],{"class":225,"line":1145},23,[223,1147,1148],{"class":357},"    response",[223,1150,815],{"class":361},[223,1152,1153],{"class":229},"raise_for_status",[223,1155,1156],{"class":361},"()\n",[223,1158,1160],{"class":225,"line":1159},24,[223,1161,448],{"class":357},[223,1163,1165,1168,1171,1173,1176],{"class":225,"line":1164},25,[223,1166,1167],{"class":781},"    return",[223,1169,1170],{"class":357}," response",[223,1172,815],{"class":361},[223,1174,1175],{"class":229},"json",[223,1177,1156],{"class":361},[11,1179,1180],{},[33,1181,1182],{},"Other tool implementations:",[11,1184,1185],{},"Similarly, implement the search and chat tools:",[166,1187,1189],{"className":773,"code":1188,"language":241,"meta":174,"style":174},"# Search tool\ndef search_handler(args: Args[Input]) -> Output:\n    url = \"https://your-domain.com:8001/product/search\"\n    payload = json.dumps{\n        \"user_id\": args.input.user_id,\n        \"query\": args.input.query,\n    })\n    headers = {\n        'Content-Type': 'application/json'\n    }\n    \n    response = requests.post(url, headers=headers, data=payload, timeout=30)\n    response.raise_for_status()\n    \n    return response.json()\n\n# Chat tool\ndef chat_handler(args: Args[Input]) -> Output:\n    url = \"https://your-domain.com:8001/product/chat/complete\"\n    payload = json.dumps({\n        \"user_id\": args.input.user_id,\n        \"query\": args.input.query\n    })\n    response = requests.post(url, json=payload, timeout=30)\n    return response.json()\n",[86,1190,1191,1196,1226,1239,1254,1276,1299,1306,1314,1330,1334,1338,1380,1390,1394,1406,1410,1415,1442,1455,1469,1491,1512,1516,1550],{"__ignoreMap":174},[223,1192,1193],{"class":225,"line":226},[223,1194,1195],{"class":941},"# Search tool\n",[223,1197,1198,1200,1203,1205,1207,1209,1211,1213,1215,1218,1221,1224],{"class":225,"line":237},[223,1199,844],{"class":353},[223,1201,1202],{"class":229}," search_handler",[223,1204,850],{"class":361},[223,1206,854],{"class":853},[223,1208,857],{"class":361},[223,1210,860],{"class":357},[223,1212,863],{"class":361},[223,1214,866],{"class":357},[223,1216,1217],{"class":361},"])",[223,1219,1220],{"class":361}," ->",[223,1222,1223],{"class":357}," Output",[223,1225,875],{"class":361},[223,1227,1228,1230,1232,1234,1237],{"class":225,"line":439},[223,1229,947],{"class":357},[223,1231,362],{"class":361},[223,1233,952],{"class":361},[223,1235,1236],{"class":233},"https://your-domain.com:8001/product/search",[223,1238,371],{"class":361},[223,1240,1241,1243,1245,1247,1249,1251],{"class":225,"line":445},[223,1242,962],{"class":357},[223,1244,362],{"class":361},[223,1246,967],{"class":357},[223,1248,815],{"class":361},[223,1250,972],{"class":890},[223,1252,1253],{"class":361},"{\n",[223,1255,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274],{"class":225,"line":451},[223,1257,980],{"class":361},[223,1259,983],{"class":233},[223,1261,365],{"class":361},[223,1263,857],{"class":361},[223,1265,885],{"class":357},[223,1267,815],{"class":361},[223,1269,891],{"class":890},[223,1271,815],{"class":361},[223,1273,983],{"class":890},[223,1275,993],{"class":361},[223,1277,1278,1280,1283,1285,1287,1289,1291,1293,1295,1297],{"class":225,"line":457},[223,1279,980],{"class":361},[223,1281,1282],{"class":233},"query",[223,1284,365],{"class":361},[223,1286,857],{"class":361},[223,1288,885],{"class":357},[223,1290,815],{"class":361},[223,1292,891],{"class":890},[223,1294,815],{"class":361},[223,1296,1282],{"class":890},[223,1298,993],{"class":361},[223,1300,1301,1304],{"class":225,"line":463},[223,1302,1303],{"class":361},"    }",[223,1305,1142],{"class":357},[223,1307,1308,1310,1312],{"class":225,"line":468},[223,1309,1054],{"class":357},[223,1311,362],{"class":361},[223,1313,1059],{"class":361},[223,1315,1316,1318,1320,1322,1324,1326,1328],{"class":225,"line":474},[223,1317,1064],{"class":361},[223,1319,1067],{"class":233},[223,1321,1070],{"class":361},[223,1323,857],{"class":361},[223,1325,1075],{"class":361},[223,1327,1078],{"class":233},[223,1329,1081],{"class":361},[223,1331,1332],{"class":225,"line":480},[223,1333,549],{"class":361},[223,1335,1336],{"class":225,"line":486},[223,1337,448],{"class":357},[223,1339,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378],{"class":225,"line":492},[223,1341,1094],{"class":357},[223,1343,362],{"class":361},[223,1345,1099],{"class":357},[223,1347,815],{"class":361},[223,1349,1104],{"class":229},[223,1351,850],{"class":361},[223,1353,1109],{"class":229},[223,1355,830],{"class":361},[223,1357,1114],{"class":853},[223,1359,362],{"class":361},[223,1361,1119],{"class":229},[223,1363,830],{"class":361},[223,1365,1124],{"class":853},[223,1367,362],{"class":361},[223,1369,1129],{"class":229},[223,1371,830],{"class":361},[223,1373,1134],{"class":853},[223,1375,362],{"class":361},[223,1377,1139],{"class":250},[223,1379,1142],{"class":361},[223,1381,1382,1384,1386,1388],{"class":225,"line":498},[223,1383,1148],{"class":357},[223,1385,815],{"class":361},[223,1387,1153],{"class":229},[223,1389,1156],{"class":361},[223,1391,1392],{"class":225,"line":504},[223,1393,448],{"class":357},[223,1395,1396,1398,1400,1402,1404],{"class":225,"line":510},[223,1397,1167],{"class":781},[223,1399,1170],{"class":357},[223,1401,815],{"class":361},[223,1403,1175],{"class":229},[223,1405,1156],{"class":361},[223,1407,1408],{"class":225,"line":516},[223,1409,839],{"emptyLinePlaceholder":838},[223,1411,1412],{"class":225,"line":522},[223,1413,1414],{"class":941},"# Chat tool\n",[223,1416,1417,1419,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440],{"class":225,"line":528},[223,1418,844],{"class":353},[223,1420,1421],{"class":229}," chat_handler",[223,1423,850],{"class":361},[223,1425,854],{"class":853},[223,1427,857],{"class":361},[223,1429,860],{"class":357},[223,1431,863],{"class":361},[223,1433,866],{"class":357},[223,1435,1217],{"class":361},[223,1437,1220],{"class":361},[223,1439,1223],{"class":357},[223,1441,875],{"class":361},[223,1443,1444,1446,1448,1450,1453],{"class":225,"line":534},[223,1445,947],{"class":357},[223,1447,362],{"class":361},[223,1449,952],{"class":361},[223,1451,1452],{"class":233},"https://your-domain.com:8001/product/chat/complete",[223,1454,371],{"class":361},[223,1456,1457,1459,1461,1463,1465,1467],{"class":225,"line":540},[223,1458,962],{"class":357},[223,1460,362],{"class":361},[223,1462,967],{"class":357},[223,1464,815],{"class":361},[223,1466,972],{"class":229},[223,1468,975],{"class":361},[223,1470,1471,1473,1475,1477,1479,1481,1483,1485,1487,1489],{"class":225,"line":546},[223,1472,980],{"class":361},[223,1474,983],{"class":233},[223,1476,365],{"class":361},[223,1478,857],{"class":361},[223,1480,885],{"class":229},[223,1482,815],{"class":361},[223,1484,891],{"class":890},[223,1486,815],{"class":361},[223,1488,983],{"class":890},[223,1490,993],{"class":361},[223,1492,1493,1495,1497,1499,1501,1503,1505,1507,1509],{"class":225,"line":552},[223,1494,980],{"class":361},[223,1496,1282],{"class":233},[223,1498,365],{"class":361},[223,1500,857],{"class":361},[223,1502,885],{"class":229},[223,1504,815],{"class":361},[223,1506,891],{"class":890},[223,1508,815],{"class":361},[223,1510,1511],{"class":890},"query\n",[223,1513,1514],{"class":225,"line":1145},[223,1515,1049],{"class":361},[223,1517,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548],{"class":225,"line":1159},[223,1519,1094],{"class":357},[223,1521,362],{"class":361},[223,1523,1099],{"class":357},[223,1525,815],{"class":361},[223,1527,1104],{"class":229},[223,1529,850],{"class":361},[223,1531,1109],{"class":229},[223,1533,830],{"class":361},[223,1535,967],{"class":853},[223,1537,362],{"class":361},[223,1539,1129],{"class":229},[223,1541,830],{"class":361},[223,1543,1134],{"class":853},[223,1545,362],{"class":361},[223,1547,1139],{"class":250},[223,1549,1142],{"class":361},[223,1551,1552,1554,1556,1558,1560],{"class":225,"line":1164},[223,1553,1167],{"class":781},[223,1555,1170],{"class":357},[223,1557,815],{"class":361},[223,1559,1175],{"class":229},[223,1561,1156],{"class":361},[23,1563,1565],{"id":1564},"step-4-publish-and-test-tools","Step 4: Publish and test tools",[11,1567,1568],{},"After publishing, you can view the plugin under \"My Resources\":",[11,1570,1571],{},[617,1572],{"alt":1573,"src":1574},"Published plugin resource","https://cdn.memt.ai/static/memos/coze_tools_3.png",[23,1576,1578],{"id":1577},"step-5-integrate-into-agent-workflow","Step 5: Integrate into agent workflow",[11,1580,1581],{},"Add the plugin into the agent workflow:",[72,1583,1584,1587,1590,1593],{},[40,1585,1586],{},"Create a new agent or edit an existing agent",[40,1588,1589],{},"Add the published MemOS plugin to the tool list",[40,1591,1592],{},"Configure the workflow to call memory tools",[40,1594,1595],{},"Test memory write and retrieval functions",[149,1597],{},[15,1599,1601],{"id":1600},"faq","FAQ",[23,1603,1605],{"id":1604},"q1-mcp-service-cannot-connect-to-server-api","Q1: MCP service cannot connect to Server API",[11,1607,1608],{},[33,1609,1610],{},"Solution:",[37,1612,1613,1619,1626],{},[40,1614,1615,1616],{},"Check whether Server API is running: ",[86,1617,1618],{},"curl http://localhost:8001/docs",[40,1620,1621,1622,1625],{},"Check whether environment variable ",[86,1623,1624],{},"MEMOS_API_BASE_URL"," is configured correctly",[40,1627,1628],{},"Check MCP service logs and confirm the call address",[23,1630,1632],{"id":1631},"q2-coze-cannot-connect-to-mcp-service","Q2: Coze cannot connect to MCP service",[11,1634,1635],{},[33,1636,1610],{},[37,1638,1639,1642,1645,1651],{},[40,1640,1641],{},"Make sure you use HTTPS",[40,1643,1644],{},"Check whether the SSL certificate is valid",[40,1646,1647,1648],{},"Test reverse proxy configuration: ",[86,1649,1650],{},"curl https://your-domain.com/mcp",[40,1652,1653],{},"Check firewall and security group settings",[23,1655,1657],{"id":1656},"q3-neo4j-connection-failed","Q3: Neo4j connection failed",[11,1659,1660],{},[33,1661,1610],{},[37,1663,1664,1667,1670],{},[40,1665,1666],{},"Ensure Neo4j service is running",[40,1668,1669],{},"Check connection info in the configuration file (uri, user, password)",[40,1671,1672,1673,1675],{},"Refer to ",[86,1674,285],{}," as an example configuration",[23,1677,1679],{"id":1678},"q4-how-to-see-complete-api-examples","Q4: How to see complete API examples?",[11,1681,1682],{},[33,1683,1684],{},"Reference files:",[37,1686,1687,1692,1698],{},[40,1688,1689,1690],{},"MCP server: ",[86,1691,407],{},[40,1693,1694,1695],{},"MCP client: ",[86,1696,1697],{},"examples/mem_mcp/simple_fastmcp_client.py",[40,1699,1700,1701],{},"API tests: ",[86,1702,1703],{},"examples/api/server_router_api.py",[149,1705],{},[15,1707,1709],{"id":1708},"summary","Summary",[11,1711,1712],{},"With this guide, you can:",[37,1714,1715,1718,1721,1724],{},[40,1716,1717],{},"✅ Choose a suitable MCP deployment option (cloud or self-hosted)",[40,1719,1720],{},"✅ Complete the full MCP service deployment process",[40,1722,1723],{},"✅ Integrate MemOS memory features into platforms like Coze",[40,1725,1726],{},"✅ Integrate directly via REST API",[11,1728,1729],{},"No matter which option you choose, MemOS can provide your agent with powerful memory managementders=headers, data=payload)\nreturn json.loads(response.text)",[272,1731,1732,1737],{},[11,1733,1734],{},[33,1735,1736],{},"API parameter notes",[37,1738,1739,1742,1751,1759,1765],{},[40,1740,1741],{},"Use the standard Server API parameter format",[40,1743,1744,1746,1747,1750],{},[86,1745,1000],{},": replaces the previous ",[86,1748,1749],{},"memory_content",", supports string or message array",[40,1752,1753,1746,1755,1758],{},[86,1754,1019],{},[86,1756,1757],{},"mem_cube_id",", supports multiple cubes",[40,1760,1761,1762],{},"Server API runs on port 8001, and the path is ",[86,1763,1764],{},"/product/add",[40,1766,1767,1768,1770,1773,1775],{},"Ensure it matches MemOS Server API interface. You can refer to the example in ",[86,1769,1703],{},[33,1771,1772],{},"IDE configuration",[280,1774],{},"In the IDE, you can customize tool parameters, return value formats, etc., ensuring consistency with MemOS API. Use this method to implement the search endpoint and user registration endpoint, then click Publish.",[23,1777,1779],{"id":1778},"publish-and-use-the-plugin","Publish and Use the Plugin",[11,1781,1782],{},"After publishing, you can view the plugin under \"My Resources\" and integrate it into the agent workflow as a plugin:",[11,1784,1785],{},[617,1786],{"alt":1573,"src":1574},[23,1788,1790],{"id":1789},"build-an-agent-and-test","Build an Agent and Test",[11,1792,1793],{},"After building the simplest agent, you can test memory operations:",[72,1795,1796,1799,1802,1805],{},[40,1797,1798],{},"Create a new agent",[40,1800,1801],{},"Add the published memory plugin",[40,1803,1804],{},"Configure the workflow",[40,1806,1595],{},[1808,1809,1810],"style",{},"html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}",{"title":174,"searchDepth":237,"depth":237,"links":1812},[1813,1817,1818,1824,1829,1836,1842],{"id":17,"depth":237,"text":18,"children":1814},[1815,1816],{"id":25,"depth":439,"text":26},{"id":106,"depth":439,"text":107},{"id":153,"depth":237,"text":154},{"id":160,"depth":237,"text":161,"children":1819},[1820,1821,1822,1823],{"id":210,"depth":439,"text":211},{"id":289,"depth":439,"text":290},{"id":410,"depth":439,"text":411},{"id":569,"depth":439,"text":570},{"id":603,"depth":237,"text":604,"children":1825},[1826,1827,1828],{"id":612,"depth":439,"text":613},{"id":623,"depth":439,"text":624},{"id":636,"depth":439,"text":637},{"id":681,"depth":237,"text":682,"children":1830},[1831,1832,1833,1834,1835],{"id":690,"depth":439,"text":211},{"id":729,"depth":439,"text":730},{"id":747,"depth":439,"text":748},{"id":1564,"depth":439,"text":1565},{"id":1577,"depth":439,"text":1578},{"id":1600,"depth":237,"text":1601,"children":1837},[1838,1839,1840,1841],{"id":1604,"depth":439,"text":1605},{"id":1631,"depth":439,"text":1632},{"id":1656,"depth":439,"text":1657},{"id":1678,"depth":439,"text":1679},{"id":1708,"depth":237,"text":1709,"children":1843},[1844,1845],{"id":1778,"depth":439,"text":1779},{"id":1789,"depth":439,"text":1790},"Configure MemOS MCP service on platforms like Coze to achieve seamless integration between agents and memory systems","md",{},"/en/open_source/best_practice/mcp_for_cozespace_and_tools",{"title":5,"description":1846},"en/open_source/best_practice/mcp_for_cozespace_and_tools","Mz2hmV4CpfytkEIljzlw3pSOKsjlRyhQkyQ5Z6UVkBc",[1854,1861],{"title":1855,"path":1856,"stem":1857,"icon":1858,"framework":6,"module":6,"class":1859,"target":-1,"active":1860,"defaultOpen":1860,"children":-1,"description":-1},"Common Errors & Solutions","/open_source/best_practice/common_errors_solutions","open_source/best_practice/common_errors_solutions","i-ri-error-warning-line",[],false,{"title":1862,"path":1863,"stem":1864,"icon":1865,"framework":6,"module":6,"class":1866,"target":-1,"active":1860,"defaultOpen":1860,"children":-1,"description":1867},"Contributing to MemOS","/open_source/contribution/overview","open_source/contribution/overview","i-ri-eye-line",[],"Welcome to the MemOS contribution guide! Learn how to set up your development environment, follow our workflow, write good commit messages, improve documentation, and add tests.",1770372090035]