findymail-mcp 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/http.js +16 -44
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "findymail-mcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "MCP server for Findymail - Find verified B2B emails, phone numbers, and company data",
5
5
  "type": "module",
6
6
  "main": "src/stdio.js",
package/src/http.js CHANGED
@@ -33,51 +33,16 @@ app.use((req, res, next) => {
33
33
  });
34
34
 
35
35
  // =============================================================================
36
- // OAuth 2.0 endpoints (required for HTTP transport)
36
+ // RFC 9728: Protected Resource Metadata
37
37
  // =============================================================================
38
38
 
39
- app.get("/.well-known/oauth-authorization-server", (req, res) => {
40
- log("OAuth metadata requested");
39
+ app.get("/.well-known/oauth-protected-resource", (req, res) => {
40
+ log("Protected resource metadata requested");
41
41
  res.json({
42
- issuer: BASE_URL,
43
- authorization_endpoint: `${BASE_URL}/authorize`,
44
- token_endpoint: `${BASE_URL}/token`,
45
- registration_endpoint: `${BASE_URL}/register`,
46
- response_types_supported: ["code"],
47
- grant_types_supported: ["authorization_code", "refresh_token"],
48
- code_challenge_methods_supported: ["S256"],
49
- token_endpoint_auth_methods_supported: ["none"],
50
- });
51
- });
52
-
53
- app.post("/register", (req, res) => {
54
- log("Client registration");
55
- const clientId = `client_${Date.now()}`;
56
- res.status(201).json({
57
- client_id: clientId,
58
- client_id_issued_at: Math.floor(Date.now() / 1000),
59
- redirect_uris: req.body?.redirect_uris || [],
60
- });
61
- });
62
-
63
- app.get("/authorize", (req, res) => {
64
- log(`Authorization requested for client: ${req.query.client_id}`);
65
- const code = `code_${Date.now()}`;
66
- const redirectUri = new URL(req.query.redirect_uri);
67
- redirectUri.searchParams.set("code", code);
68
- if (req.query.state) {
69
- redirectUri.searchParams.set("state", req.query.state);
70
- }
71
- log("Auto-approving authorization");
72
- res.redirect(redirectUri.toString());
73
- });
74
-
75
- app.post("/token", (req, res) => {
76
- log("Token exchange");
77
- res.json({
78
- access_token: `access_${Date.now()}`,
79
- token_type: "Bearer",
80
- expires_in: 3600,
42
+ resource: BASE_URL,
43
+ authorization_servers: ["https://app.findymail.com"],
44
+ scopes_supported: ["mcp:full"],
45
+ bearer_methods_supported: ["header"],
81
46
  });
82
47
  });
83
48
 
@@ -101,13 +66,20 @@ function createMcpServer() {
101
66
  // =============================================================================
102
67
 
103
68
  app.use("/mcp", (req, res, next) => {
69
+ const wwwAuth = `Bearer resource_metadata="${BASE_URL}/.well-known/oauth-protected-resource"`;
104
70
  const authHeader = req.headers.authorization;
105
71
  if (!authHeader || !authHeader.startsWith("Bearer ")) {
106
- return res.status(401).json({ error: "Authorization header with Bearer token is required" });
72
+ return res
73
+ .status(401)
74
+ .set("WWW-Authenticate", wwwAuth)
75
+ .json({ error: "Authorization header with Bearer token is required" });
107
76
  }
108
77
  const token = authHeader.slice(7).trim();
109
78
  if (!token) {
110
- return res.status(401).json({ error: "Bearer token is empty" });
79
+ return res
80
+ .status(401)
81
+ .set("WWW-Authenticate", wwwAuth)
82
+ .json({ error: "Bearer token is empty" });
111
83
  }
112
84
  req.auth = { token, clientId: "", scopes: [] };
113
85
  next();